3

I have a VB6 program. It is compiled (no buildable source) and comprised of an .EXE and a few .DLLs.

I created a simple Python script to call some of the public methods in the libraries. Unfortunately, none the methods are available in Python or I'm not calling them correctly.

The code:

from ctypes import *

test = windll.LoadLibrary("C:/.../ComDlg32.ocx")

print test
print test.DLLGetDocumentation

outputs this:

<WinDLL 'C:/.../ComDlg32.ocx', handle 217a0000 at 23a3b10>
<_FuncPtr object at 0x023834E0>

Process finished with exit code 0

I'm okay with the results shown above. It gives me more information than when I run the same code and try to use one of our own DLLs. I think Comdlg32.ocx is a vender-provided control.

When I run the same code against one of our own DLLs with a method that, without a doubt, exists in the DLL, I get this:

Traceback (most recent call last):
<WinDLL 'C:/.../ABC123.exe', handle 5f0000 at 2373b30>
  File "C:/.../XYZ123.py", line 11, in <module>
    print test.Init
  File "C:\...\lib\ctypes\__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "C:\...\lib\ctypes\__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Init' not found

Process finished with exit code 1

The above result is from an EXE but a DLL returns the same results, minus the method name.

I tried using DUMPBIN with the /exports option. It doesn't show me any of the public methods. DUMPBIN is how I found DLLGetDocumentation in the OCX.

Is there anything else I can try to call methods in a VB6 DLL? Does the VB6 project need to be compiled with specific switches in order for public methods to be callable from Python? How can I tell / verify if the VB6 was compiled in a manner than should allow methods to be callable?

DenaliHardtail
  • 27,362
  • 56
  • 154
  • 233
  • 4
    VB6 builds ActiveX DLLs. Here is a link to a question that answers this. http://stackoverflow.com/questions/1065844/what-can-you-do-with-com-activex-in-python – jac Feb 10 '15 at 23:31

0 Answers0