Re: Acquiring process handle and convert it into PID

eryk sun <[email protected]> Wed, 30 Nov 2016 16:24:18 +0000
Newsgroups gmane.comp.python.ctypes
Message-ID <CACL+1avS9pkqr9=cqE2_mGS0qD_DR6SU0xobR-=T+hLbBjhLPg@mail.gmail.com>
On Wed, Nov 30, 2016 at 4:15 PM, Michael C
<[email protected]> wrote:
> if I still want to use Windll somehow, since I need windows API, how should
> I do it?

Use WinDLL instead of windll, e.g.:

    kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)

Using ctypes.windll is unreliable in principle. It caches instances of
WinDLL, which cache function pointer objects. Thus other libraries can
modify function prototypes (i.e. restype, argtypes, errcheck) in ways
that break your code.

------------------------------------------------------------------------------