[issue9055] test_issue_8959_b fails when run from a service
Hirokazu Yamamoto
report at bugs.python.org
Mon Oct 11 12:07:41 CEST 2010
Hirokazu Yamamoto <ocean-city at m2.ccsnet.ne.jp> added the comment:
Hello. I've been finding the way to determine whether
the process is running as service or not. Does this way
work? On my environment, True is returned. I hope False
will be returned in service environment.
http://msdn.microsoft.com/en-us/library/d56de412%28v=VS.80%29.aspx
http://msdn.microsoft.com/en-us/library/ms683225%28VS.85%29.aspx
/////////////////////////////////////////
from __future__ import print_function
import ctypes
from ctypes.wintypes import *
UOI_FLAGS = 1
WSF_VISIBLE = 0x0001
class USEROBJECTFLAGS(ctypes.Structure):
_fields_ = [("fInherit", BOOL),
("fReserved", BOOL),
("dwFlags", DWORD)]
def window_station_has_display_surfaces():
dll = ctypes.windll.user32
h = dll.GetProcessWindowStation()
if not h:
raise ctypes.WinError()
uof = USEROBJECTFLAGS()
needed = DWORD()
res = dll.GetUserObjectInformationW(h,
UOI_FLAGS,
ctypes.byref(uof),
ctypes.sizeof(uof),
ctypes.byref(needed))
if not res:
raise ctypes.WinError()
return bool(uof.dwFlags & WSF_VISIBLE)
def main():
print(window_station_has_display_surfaces())
if __name__ == '__main__':
main()
----------
nosy: +ocean-city
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9055>
_______________________________________
More information about the Python-bugs-list
mailing list