Skip to content Skip to sidebar Skip to footer

Does Python's Ctypes C_char Work For Windows 64?

I'm trying to load a process list, and it functions correctly on 32bit python. However, on 64bit, I can't get the process name to list. The code is below. If I change szExeFile'

Solution 1:

Your PROCESSENTRY32 structure is wrong. This works for me:

class PROCESSENTRY32(Structure):
    _fields_ = [ ( 'dwSize' , DWORD ) ,
                 ( 'cntUsage' , DWORD) ,
                 ( 'th32ProcessID' , DWORD) ,
                 ( 'th32DefaultHeapID' , POINTER(ULONG)) ,
                 ( 'th32ModuleID' , DWORD) ,
                 ( 'cntThreads' , DWORD) ,
                 ( 'th32ParentProcessID' , DWORD) ,
                 ( 'pcPriClassBase' , LONG) ,
                 ( 'dwFlags' , DWORD) ,
                 ( 'szExeFile' , c_char * 260 ) ]

Post a Comment for "Does Python's Ctypes C_char Work For Windows 64?"