On Aug 12, 2014, at 4:28 AM, Christiaan B v Zyl <christiaanvan...@gmail.com<mailto:christiaanvan...@gmail.com>> wrote: I have a DLL, it is an SDK for the Pastel Partner accounting system. Using Dependency Walker I can see that the DLL has the following methods: DllRegisterServer, DllUnregisterServer, DllGetClassObject
With the library there came a sample VB program that referenced the DLL and instantiated it like this: Dim SDK As New PasSDK.PastelPartnerSDK The only way I've been able to use this library from python is to register it with Windows: regsvr32 PasSDK.dll And then use it in python like this: import win32com.client sdk = win32com.client.Dispatch(PasSDK.PastelPartnerSDK") sdk.SetLicense(...) etc... However, is there a way to use this library directly without registering it first? Something like: from ctypes import * sdk = cdll.LoadLibrary('PasSDK.dll') When I do this I can see that sdk.DllGetClassObject is a function, but how do I instantiate it like the VB program, is it possible? Are you saying that the VB program works correctly without registering the DLL first? COM servers are always accessed through the registry. The only way the operating system know where to look for the DLL is by looking in the registry. From the “PasSDK.PastelPartnerSDK” class name, it finds the COM class GUID. From the GUID, it finds the path to the DLL. Now, regsvr32 does nothing except load the DLL and call DllRegisterServer. So, you could, in fact, do this: sdk = cdll.LoadLibrary(‘PasSDK.dll’) sdk.DllRegisterServer() and then call Dispatch. I’m not sure this is any better than, for example: os.system(‘regsvr32 passdk.dll’) -- Tim Roberts, t...@probo.com<mailto:t...@probo.com> Providenza & Boekelheide, Inc.
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32