1

i am trying to use kernal32 dll and use functions from it. when trying to do that, i got the error.

Traceback (most recent call last): File "C:\Users\Tawfiq\Desktop\2D render\win32.py", line 2, in <module> mydll = cdll.LoadLibrary(r"C:\Windows\SysWOW64\kernel32.dll") File "C:\Program Files\Python39\lib\ctypes\__init__.py", line 452, in LoadLibrary return self._dlltype(name) File "C:\Program Files\Python39\lib\ctypes\__init__.py", line 374, in __init__ self._handle = _dlopen(self._name, mode) OSError: [WinError 193] %1 is not a valid Win32 application 

this is the code i am executing:

from ctypes import* mydll = cdll.LoadLibrary(r"C:\Windows\SysWOW64\kernel32.dll") print(mydll.timeGetTime()) 
0

1 Answer 1

2

c:\windows\syswow64 contains 32-bit DLLs. Your Python path is c:\Program Files which is the 64-bit Python installation location. You can't mix.

Don't hard-code the path. Just use mydll = WinDLL('kernel32') and Windows will search the correct standard location for the Python running (32- or 64-bit).

Sign up to request clarification or add additional context in comments.

1 Comment

yes, i tried it and it works

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.