I have found a bug in the gpib-ctypes loading of DLL’s. It will fail if gpib-32.dll contains dependencies to other DLL’s outside the system32 directory.
For example the “Keysight_Instrument_Control_Bundle” installs the following files:
C:\Windows\System32\gpib-32.dll
C:\Program Files\Keysight\IO Libraries Suite\bin\ioPersistedDataAccess.dll
But ctypes calls LoadLibraryEx with dwFlags=LOAD_LIBRARY_SEARCH_DEFAULT_DIRS causing it to fail to load the ioPersistedDataAccess.dll since it is not in the System32 folder.
One solution is to set winmode=0 in ctypes like this:
_lib = ctypes.WinDLL(libname, winmode = 0)
My code changes are:
diff --git "a/gpib_orig.py" "b/gpib.py"
index 64bb0e8..b822ebc 100644
--- "a/gpib_orig.py"
+++ "b/gpib.py"
@@ -32,15 +32,16 @@ def _load_lib(filename=None):
'c:\\windows\\system\\gpib-32.dll',
'c:\\gpib\\gpib-32.dll',
'gpib-32.so', 'libgpib.so.0']
- loader = ctypes.windll.LoadLibrary
else:
# most likely Linux with linux-gpib
libnames = [filename] if filename else ['libgpib.so.0', 'gpib-32.so']
- loader = ctypes.cdll.LoadLibrary
for libname in libnames:
try:
- _lib = loader(libname)
+ if platform.system() == "Windows":
+ _lib = ctypes.WinDLL(libname, winmode = 0)
+ else:
+ _lib = ctypes.cdll.LoadLibrary(libname)
break
except OSError:
continue
I have found a bug in the gpib-ctypes loading of DLL’s. It will fail if gpib-32.dll contains dependencies to other DLL’s outside the system32 directory.
For example the “Keysight_Instrument_Control_Bundle” installs the following files:
C:\Windows\System32\gpib-32.dll
C:\Program Files\Keysight\IO Libraries Suite\bin\ioPersistedDataAccess.dll
But ctypes calls LoadLibraryEx with dwFlags=LOAD_LIBRARY_SEARCH_DEFAULT_DIRS causing it to fail to load the ioPersistedDataAccess.dll since it is not in the System32 folder.
One solution is to set winmode=0 in ctypes like this:
_lib = ctypes.WinDLL(libname, winmode = 0)
My code changes are: