Reputation: 75
Sorry my English is very bad.
So.
I write simple Dynamic Link Library in Dev c++.
Its working nice.Today I import this is library in my python project.
Dynamic Link Library File Path:lib/my_dll.dll
#Dialog box
config.py
DLL_PATH = "lib/my_dll.dll"
main.py(config.py)imported
def my_func():
dll = CDLL(DLL_PATH)
return dll.func1()
So i open python interpreter and write this.
from main import *
a = my_func() #Its work nice so a == "c:\\Windows\\a.txt"
but i reuse this function python generate next error
OSErrror:[WinError 126] The specified module could not be found
Thank you for reading!
Upvotes: 1
Views: 1440
Reputation: 612794
In the comments you state that your DLL function call an API function that shows a file selection dialog. File selection dialogs, unless you tell them not to, can change the working directory. Since you failed to specify a full path to the DLL, the DLL search is performed each time. The first time it succeeds because your working directory happens to be what is needed for the DLL to be found. Subsequent times the DLL search fails because your working directory has changed.
Some advice:
restype
and so I don't see how you can obtain text from that function. What's more, I don't see how you can avoid leaking memory each time you call the function. Unless the text lives in a static array.Upvotes: 1