Hi,
I have written a DLL in C/C++ which uses COM internally.
While trying to call function in DLL, I have found out that COM is not getting initialised. I am initialising COM in C.
consider following example
IN C/C++
#define DLLEXPORT extern "C" __declspec(dllexport)
DLLEXPORT int Init_COM()
{
int result = 1;
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (FAILED(hr))
{
result = -8;
}
else
{
}
return result;
}
DLLEXPORT int some_function()
{
CComPtr<IPortableDeviceManager> pPortableDevice;
.
.
.
return some_val;
}
The value returned in python in -8, meaning COM initialization Failed. I am very new to python and hence don't know how to use function written in c/c++ in a DLL using COM in python! Please HELP..
IN Python I import the DLL
from ctypes import *
cdll.LoadLibrary("MY_DLL.dll") as my_dll #or import MY_DLL.dll
return_val = my_dll.Init_COM() #returns -8
return_val = my_dll.some_function() #wont work
I dont exactly remember python syntax so there might be some error above!
Thank You