Solved

Problem spawning a regular win32 application from NT service

Posted on 1998-07-16
7
251 Views
Last Modified: 2013-11-20
Hello,

Using the sample code from "Creating a Simple Window NT Service in C++" by Nigel Thompson from Microsoft's technical article in the MSDN CDs, I created my own NT service that spawns another Win32 application called "ServerApp".  After the NT service starts,  the ServerApp is created using CreateProcess().

STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
CreateProcess(NULL, "C:\\ServerApp", NULL, NULL, FALSE,
                              0, NULL, NULL, &si, &pi);

However, for some reason, the ServeApp stays in a wait state and never completes the execution.  Even after the NT service is stopped, the ServeApp remains in the wait state.  I can't even kill the process.  How can I get the process to start?

Thanks,

Jennifer
0
Comment
Question by:jli
7 Comments
 
LVL 7

Expert Comment

by:psdavis
ID: 1319343
Have you tried ShellExecute?

ShellExecute( this->GetSafeHwnd( ), "open", strEngine, NULL, strDirectory, SW_SHOWMINIMIZED );

Phillip

0
 

Author Comment

by:jli
ID: 1319344
In NT Service, there is no Windows handle associated with the process.
0
 
LVL 8

Expert Comment

by:trestan
ID: 1319345
There is no problem in the codes you listed here. Would you provide more information about the case? Did you debug your code to see where the program blocked? Or email me your codes: trestan@hotmail.com
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Rajkumar_R
ID: 1319346
I think the problem must be in your other exe ServerApp
0
 

Expert Comment

by:ahomer
ID: 1319347
try using  ---

if(::CreateProcess(NULL, "C:\\ServerApp", NULL, NULL, FALSE,
0, NULL, NULL, &si, &pi)){
   ::CloseHandle (pi.hThread);
   ::CloseHandle (pi.hProcess);
}            

0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
ID: 1319348
Your problem does not come from CreateProcess, but from the special environment of services. Take a look at this URL for a more complete discussion of the problem.

http://www.microsoft.com/msj/0398/service2.htm


0
 

Author Comment

by:jli
ID: 1319349
Thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
string initialization in java 11 117
isEverywhere  challenge 19 85
matchUp  challenge 6 76
child constructor and parent constructor, overriding and overloading 6 93
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question