Re: ctypes.CDLL("") fails on MS Windows

Thomas Heller <[email protected]> Thu, 22 Dec 2011 09:00:21 +0100
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Am 22.12.2011 08:21, schrieb Hart's Antler:
> In Linux passing an empty string to ctypes.CDLL("") will return a handle
> to the current process, this can be useful to get to extra functions
> when Python is embedded. On Windows this trick fails, and raises a
> WindowsError.

On Windows, you can use something like this:

exe = ctypes.CDLL("myprocess",
                   ctypes.windll.kernel32.GetModuleHandleA(None))

to get the current process.  However, I'm not sure if this makes
sense:  an exe cannot export functions.

> As a workaround i tried loading cygwin1.dll from ctypes and using dlopen
> directly, but the call blocks and never returns.

I don't know anything about cygwin.

Thomas

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev