[python-win32] pythoncom.CoCreateInstance(...) problems
Pete Hodgson
email at thepete.net
Sun Oct 24 02:42:29 CEST 2004
Hi all,
Firstly, apologies for any dumbness, I'm a python newbie.
I'm trying to use pythoncom to build a DirectShow Filter Graph, but I'm
having problems getting the correct COM interface with
pythoncom.CoCreateInstance(...). To try and diagnose the problem, I've
written a toy C program which seems to me to be directly equivalent to
the python script I'm having problems with. Here are the two programs:
<------------START OF MY PYTHON IMPLEMENTATION--------------------->
import pythoncom
CLSID_FilterGraph =
pythoncom.MakeIID('{E436EBB3-524F-11CE-9F53-0020AF0BA770}')
IID_IGraphBuilder =
pythoncom.MakeIID('{56A868A9-0AD4-11CE-B03A-0020AF0BA770}')
print "CLSID_FilterGraph:", CLSID_FilterGraph
print "IID_IGraphBuilder:", IID_IGraphBuilder
pythoncom.CoInitialize()
IFilterGraph = pythoncom.CoCreateInstance( CLSID_FilterGraph, None,
pythoncom.CLSCTX_INPROC_SERVER, IID_IGraphBuilder )
<------------END OF MY PYTHON IMPLEMENTATION--------------------->
When I run the above from IDLE, I get the following:
<----------PYTHON OUTPUT--------------->
IDLE 1.0.3 ==== No Subprocess ====
>>>
CLSID_FilterGraph: {E436EBB3-524F-11CE-9F53-0020AF0BA770}
IID_IGraphBuilder: {56A868A9-0AD4-11CE-B03A-0020AF0BA770}
Traceback (most recent call last):
File "D:\work\Personal\RM2MP3\rm2mp3.py", line 11, in ?
IFilterGraph = pythoncom.CoCreateInstance( CLSID_FilterGraph, None,
pythoncom.CLSCTX_INPROC_SERVER, IID_IGraphBuilder )
TypeError: There is no interface object registered that supports this IID
>>>
<------END PYTHON OUTPUT--------------->
<------------START OF MY C IMPLEMENTATION--------------------->
#include "stdafx.h"
#include "dshow.h"
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
if( FAILED( CoInitialize(NULL) ) )
return -1;
GUID _CLSID_FilterGraph;
UuidFromString(
(unsigned char*)"E436EBB3-524F-11CE-9F53-0020AF0BA770"
, &_CLSID_FilterGraph );
GUID _IID_IGraphBuilder;
UuidFromString(
(unsigned char*)"56A868A9-0AD4-11CE-B03A-0020AF0BA770"
, &_IID_IGraphBuilder );
IGraphBuilder *pIGraphBuilder;
hr = CoCreateInstance(
_CLSID_FilterGraph, NULL
, CLSCTX_INPROC_SERVER, IID_IGraphBuilder
, (void**) &pIGraphBuilder );
if( FAILED(hr) )
return -2;
return 0;
}
<------------END OF MY C IMPLEMENTATION--------------------->
The above C implementation compiles and runs fine, returning
"CoCreateInstance(...) succeeded".
Can anyone see why the C implementation works and the python one
doesn't? I'm using the same CLSIDs and IIDs for both, and calling
CoCreateInstance(...) in an identical manner. Any suggestions gratefully
received!
Cheers,
Pete
More information about the Python-win32
mailing list