GUID and ctypes
Radek Holý <[email protected]> Thu, 9 Aug 2012 09:31:27 +0200
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CAJ9iWDni=yEivgEgXjVwDmQX7FqMohC0M0strMDHyx4raCsZbg@mail.gmail.com> |
Hello,
I try to use the WinApi library powrprof.dll, but I cannot figure out
how to deal with the GUID.
I found a definition in comtypes and in the following example it works fine:
>>> array = ctypes.c_byte*8
>>> guid = GUID()
>>> guid.Data1 = 2709787400
>>> guid.Data2 = 13633
>>> guid.Data3 = 20395
>>> guid.Data4 = array(188,129,247,21,86,242,11,74)
>>> ctypes.windll.powrprof.PowerSetActiveScheme(None, ctypes.byref(guid))
But if I try the opposite example, I get the error ERROR_INVALID_PARAMETER:
>>> guid = GUID()
>>> ctypes.windll.powrprof.PowerGetActiveScheme(None, ctypes.byref(guid))
0
>>> str(guid)
'{003A66B8-0000-0000-0000-000000000000}'
>>> ctypes.windll.powrprof.PowerSetActiveScheme(None, ctypes.byref(guid))
87
Please tell me what's wrong - whether in the way I work with GUID,
ctypes or WinAPI.
Thank you very much,
--
Radek Holý
Czech republic
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/