lorenzo.mentas...@yahoo.it schrieb: > Hi all, > I need to call GetSystemPowerState windows api from pythonCE, because > I need to know if a windows ce 5 device is in sleep/off status. > I can find this api in ctypes.windll.coredll, but I cannot figure out > how to pass parameters to this procedure: msdn giude ( > http://msdn.microsoft.com/en-us/library/ms899319.aspx ) speaks about 3 > parameters, of wich 2 are output: a "LPWSTR pBuffer" and a "PDWORD > pFlags". Returned value of the call is an exit status code > rappresenting if call succeded or failed. > > I tried to call this api in several ways, but obtained always exit > code 87 (meaning that parameters are wrong) or 122 (meaning "pBuffer" > variable is too small, in this case I passed None as pBuffer, since > I'm interested only in pFlags result). > > Have you any idea? Maybe another api or way to perform this simple > task?
Python 2.5 (release25-maint, Dec 19 2006, 23:22:00) [MSC v.1201 32 bit (ARM)] on win32 >>> from ctypes import * >>> d=windll.coredll >>> d.GetSystemPowerState <_FuncPtr object at 0x0016EC60> >>> p=create_unicode_buffer(256) >>> flags=c_ulong() >>> f=d.GetSystemPowerState >>> f(p,256,byref(flags)) 0 >>> p.value u'on' >>> flags c_ulong(268500992L) >>> hex(flags.value) '0x10010000L' >>> Thomas -- http://mail.python.org/mailman/listinfo/python-list