I\'m creating a Windows Service with Delphi. What my service needs to do is basically open a program.
In my code I\'m using WinExec(aux,SW_SHOWNORMAL);
. When I star
Services always run in Session 0. A process started by a service runs in the service's Session by default, unless the service uses CreateProcessAsUser()
to run the process in a different Session.
In XP and earlier, the first user to log in also runs in Session 0 (subsequent users to login run in Sessions 1+). Thus, if the service is marked as Interactive when it is installed and it runs a process that has a UI, a user running in Session 0 can see the UI.
In Vista and later, this is no longer possible. Users never run in Session 0 anymore, and services cannot be marked as Interactive anymore. This is known as "Session 0 Isolation". A service must use CreateProcessAsUser()
now in order to run a UI process in an Interactive Session so a user can see it.
Refer to MSDN for more details:
Session 0 Isolation
Impact of Session 0 Isolation on Services and Drivers in Windows
Calling CreateProcessAsUser() from service
Launching an interactive process from Windows Service in Windows Vista and later
CreateProcessAsUser function