I am trying to create a process from a service in C++. This new process is creating as a child process. I want to create an independent process and not a child process...
I am using CreateProcess function for the same. Since the new process i create is a child process when i try to kill process tree at the service level it is killing the child process too... I dont want this to happen. I want the new process created to run independent of the service.
Please advice on the same.. Thanks..
Code
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si); // Start the child process.
ZeroMemory( &pi, sizeof(pi) );
si.dwFlags = STARTF_USESHOWWINDOW;
if(bRunOnWinLogonDesktop)
{
if(csDesktopName.empty())
si.lpDesktop = _T("winsta0\\default");
else
_tcscpy(si.lpDesktop, csDesktopName.c_str());
}
if(bHide)
si.wShowWindow = SW_HIDE; /* maybe even SW_HIDE */
else
si.wShowWindow = SW_SHOW; /* maybe even SW_HIDE */
TCHAR szCmdLine[512];
_tcscpy(szCmdLine, csCmdLine.c_str());
if( !CreateProcess( NULL,
szCmdLine,
NULL,
NULL,
FALSE,
CREATE_NEW_PROCESS_GROUP,
NULL,
NULL,
&si,
&pi ) )