Hirokazu Yamamoto <ocean-c...@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 <rep...@bugs.python.org> <http://bugs.python.org/issue9055> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com