Message118348
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() |
|
Date |
User |
Action |
Args |
2010-10-11 10:07:42 | ocean-city | set | recipients:
+ ocean-city, theller, paul.moore, amaury.forgeotdarc, tim.golden, brian.curtin |
2010-10-11 10:07:41 | ocean-city | set | messageid: <1286791661.81.0.977211875847.issue9055@psf.upfronthosting.co.za> |
2010-10-11 10:07:39 | ocean-city | link | issue9055 messages |
2010-10-11 10:07:38 | ocean-city | create | |
|