Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

::FindWindow fails from Service application

Windows API ::FindWindow function fails when called from Service application. GetLastError() also returns 0 (success?). Is this some privilege\access right problem? Do you think it's design problem and I should use another IPC method?

like image 694
bgee Avatar asked Dec 22 '22 13:12

bgee


2 Answers

leppie's right, Windows services are usually denied in interaction with desktop. You can bypass that in XP and earlier versions but won't be able to do in Vista and above. You'd better delegate desktop and user interactions to a GUI application. See this document for details.

like image 171
Claymore Avatar answered Dec 25 '22 01:12

Claymore


Services run in Session 0. On XP and earlier, the first user to log in also runs in Session 0, and subsequent users run in Sessions 1 and higher. If the service is set to "Interact with the Desktop", then it can access any user windows running in Session 0. However, starting with Vista, users never run in Session 0 anymore. FindWindow() only works in the context of the Session it is called in, as windows cannot be accessed across Session boundaries.

like image 32
Remy Lebeau Avatar answered Dec 25 '22 02:12

Remy Lebeau