2012/8/8 Roger Upole <rup...@hotmail.com>: > It's not really OT here, as there is a good bit of general discussion > regarding Python and Windows, not just Pywin32. > There's also a ctypes mailing list: > https://lists.sourceforge.net/lists/listinfo/ctypes-users
Thank you very much, I'll try this discussion. However, I have discovered that the cause of the error is that I do not pass the pointer. So the correct code is: >>> import ctypes >>> class GUID(ctypes.Structure): ... _fields_ = [ ... ('Data1', ctypes.c_ulong), ... ('Data2', ctypes.c_ushort), ... ('Data3', ctypes.c_ushort), ... ('Data4', ctypes.c_ubyte*8), ... ] ... def __str__(self): ... return "{%08x-%04x-%04x-%s-%s}" % ( ... self.Data1, ... self.Data2, ... self.Data3, ... ''.join(["%02x" % d for d in self.Data4[:2]]), ... ''.join(["%02x" % d for d in self.Data4[2:]]), ... ) ... >>> array = ctypes.c_ubyte*8 >>> guid = GUID(ctypes.c_ulong(2709787400), 13633, 20395, >>> array(188,129,247,21,86,242,11,74)) >>> ctypes.windll.powrprof.PowerSetActiveScheme(None, ctypes.byref(guid)) But there still must be a bug in the GUID class, because calling the function ``PowerGetActiveScheme`` I do not receive the same GUID. -- Radek Holý Czech republic _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32