Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Vic
Wed, 09 Apr 2003 15:10
Open one application from a service
Author: Vic
Date: Wed, 09 Apr 2003 15:10
Date: Wed, 09 Apr 2003 15:10
12 lines
1288 bytes
1288 bytes
I've got a service, and I want to open one app. this is the code : ShellExecute(GetDesktopWindow(), "open", "calc.exe",NULL, NULL,SW_SHOW); the problem is that when the ShellExecute is executed, a process called "calc.exe" is added to process list, but the app is not visible. How can I solve it ? -- Victor ESPA Inform�tica.
Re: Open one application from a service
Author: Nico Bendlin
Date: Wed, 09 Apr 2003 15:22
Date: Wed, 09 Apr 2003 15:22
37 lines
2304 bytes
2304 bytes
Vic wrote: > I've got a service, and I want to open one app. > this is the code : > > ShellExecute(GetDesktopWindow(), "open", "calc.exe",NULL, NULL,SW_SHOW); > > the problem is that when the ShellExecute is executed, a process called > "calc.exe" is added to process list, but the app is not visible. > How can I solve it ? Calc is now running on another desktop. This is because your service is running as LocalSystem and has nothing to do with the interactive desktop (namely 'WinSta0\Default') but is running on his own 'service session desktop'. Further the application is running with the credentials of LocalSystem too. But SYSTEM is not allowed (by the security descriptor of the window station / desktop) to do something an the interactive desktop. Therefore you have at least three options: - use RunAs service / API (newer windows) - start the program as the logged-in user - modify the DACLs of the winsta/desktop Nothing of these options are trivial. Finally there is still A LOT of work to get it running corretly on Windows Terminal Server (Windows XP uses TS to implement Fast User Switsching (FUS)). -- "Sure, I want to be 25 years old again with $50 billion, so I can party, but it ain't gonna happen." -- David J. Craig
Re: Open one application from a service
Author: Remy Lebeau (TeamB)
Date: Wed, 09 Apr 2003 16:58
Date: Wed, 09 Apr 2003 16:58
25 lines
1940 bytes
1940 bytes
"Vic" <victor@espainformatica.com> wrote in message
news:3e9437a8@newsgroups.borland.com...
> the problem is that when the ShellExecute is executed, a
> process called "calc.exe" is added to process list, but the
> app is not visible. How can I solve it ?
Services run under their own desktop which is separate from the visual
desktop that the user sees. As such, when you spawn a process from a
service, the process runs under the service's desktop, not the user's. That
is why you can't see it.
You need to use CreateProcess() instead of ShellExecute(). The STARTUPINFO
structure that you pass to CreateProcess() contains an lpDesktop field that
you can fill in with the name of the correct desktop that the process should
run under, ie:
STARTUPINFO si = {0};
si.lpDesktop = "WinSta0\\Default";
...
CreateProcess(..., &si, ...);
Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads