dll in project?

Alf P. Steinbach alfps at start.no
Mon Mar 15 05:19:41 CET 2010


* Alex Hall:
> Hi all,
> I have a dll I am trying to use, but I get a Windows error 126, "the
> specified module could not be found". Here is the code segment:
> nvdaController=ctypes.windll.LoadLibrary("nvdaControllerClient32.dll") 	
> 
> I have the specified dll file in the same directory as the file trying
> to use said dll, and this is the only reference I make to the dll. Do
> I need to register it somehow? If so, does this need to be done once,
> or each time the application runs? If I need to register it, how would
> I do so? Thanks!

If 'ctypes.windll.LoadLibrary' just calls the Windows API LoadLibrary function 
without adding any path, then the directories considered will only be those 
known to the Windows API, like e.g. the process' current directory (I'm not sure 
if the current directory is considered, but the details aren't important).

And most likely your calling script file is not in any of those directories.

Probably it will work to specify the full path to the DLL. You can obtain the 
path to the calling file's directory by using the __file__ variable and the 
'os.path' functions.


Cheers & hth.,

- Alf



More information about the Python-list mailing list