Service launching an application with a dialog

S

Steve Wagner

Dear Community,

Well, so I'm learning...I have a normal dialog application that I want to
launch automatically after computer bootup, then keep it running in case it
crashes. Sorry, the op-sys has challenges so I haven't used the registry to
auto-launch it.

I wrote a service that uses CreateProcess(), which of course launches our
app. We then poll the app for being alive with WaitForSingleObject(), give
it a second's worth, and hope the results is a timeout. If not, we restart
the app. It works great, however one bummer. No dialog.

Fine, the service utility has its own console or not, but launching a dialog
from the service doesn't work. So how do I get it to show?

Maybe there's a better way. Your expertise would be greatly appreciated!

Steve
 
J

John Phillips

Basically, you need to enumerate the desktops in the system, then call
CreateProcess() with the appropriate desktop (however you determine that)
passed as part of the STARTUPINFO parameter.

I haven't specified how to find the "appropriate" desktop, because there are
some complications with finding the "logged in user", especially with
respect to WTS environments or multiple user logons in XP.

When you configure a service, you can check the "Interact with Desktop"
option, however this opens up numerous possible security holes. Check
Google for numerous lengthy discussions of this option (the suggestion has
been made that MS may not allow this option in the future).


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top