C DLL loads in C++ program, not in python Ctypes

Use Sysinternals Process Monitor. Configure it to monitor the python.exe process for CreateFile operations:

Process Monitor Filter dialog

Then run your script. In the example below, I ran:

>>> from ctypes import *
>>> CDLL('x')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\dev\Python33x64\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

x.dll does not exist, with the following result near the bottom of the trace, but note that any missing dependent DLL would show up similarly:

Process Monitor trace

Leave a Comment