> I created a COM object that I've packaged up with py2exe. I have
> py2exe creating both a .exe and .dll. I've tested the .exe with
> both Python and Visual Basic and it works perfectly. I've spent
> the last hour or so trying to get to the methods (functions) of
> my .dll version to make sure it works.
The simplest way is to unregister the .exe, and register the .dll. Your
test code should then work unchanged.
Note that from Python, you can control which one to load by using
win32com.client.DispatchEx(), passing either CLSCTX_INPROC or
CLSCTX_LOCAL_SERVER in the 'clsctx' param.
> So far I've figured out that I do something like:
> >>> oC=oledll.LoadLibrary(r'c:\Program
> <OleDLL 'c:\Program Files\Syscon\wsAPICOM\wsAPICOM.dll',
> handle 3d80000 at 37b8e70>
> but after that I'm stumped.
> I tried:
> WSsettrace is one of my methods that should begin tracing
> and I get:
> Traceback (most recent call last):
> File "<interactive input>", line 1, in <module>
> File "C:\Python25\Lib\ctypes\__init__.py", line 303, in __getattr__
> return self.__getitem__(name)
> File "C:\Python25\Lib\ctypes\__init__.py", line 306, in __getitem__
> func = self._FuncPtr((name_or_ordinal, self))
> AttributeError: function 'WSsettrace' not found
LoadLibrary does not help (pywin32) in calling functions inside the DLL -
either normal ones, or COM ones. I see you are trying to use ctypes, but
COM is quite a different beast and unlikely to work. Using comtypes might
help, but pywin32 should work just fine.
> >>> oC
> <_FuncPtr object at 0x01CB6648>
> >>> oC(1)
> I have no idea what the first function would be. I tried 1,2,3,4,5
> and got AttributeError: function ordinal 5 not found on the last one.
> I have about 20 methods on this COM object, so that isn't working.
In COM, all methods are on an object, not global. The only public functions
a COM DLL generally has are specific to the COM implementation.