What can Services do under Windows?

后端 未结 5 490
谎友^
谎友^ 2021-01-03 15:04

Does anyone have a good guide to capabilities of Windows Services under XP? In particular, I am trying to find out what happens when a program being run as a service tries t

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 15:29

    A service in Windows XP can interact with the Desktop if its "Allow Service to Interact with Desktop" property (MMC -> service properties -> Log On tab) is checked. It is also possible to do so by doing the following:

    hWinstation = OpenWindowStation("winsta0", FALSE, MAXIMUM_ALLOWED);
    SetProcessWindowStation(hWinstation);
    hDesktop = OpenDesktop("default", 0, FALSE, MAXIMUM_ALLOWED);
    SetThreadDesktop(hDesk);
    

    But be aware that presenting UI from a service process in Windows XP will almost always lead to a security problem (see Shatter attack). You should try to break out the UI part of your application from the service.

提交回复
热议问题