Tech Support > Microsoft Windows > Development Resources > COM CreateProcess Problem
COM CreateProcess Problem
Posted by Stephan on June 25th, 2003


I am trying to within my COM server that runs as a certain user
IUSR_WHATEVER call into a server interface ISomeInferface that runs as
SYSTEM. The Interace function I am calling is suppose to call
CreateProcess and pass to the win32 executable a handle that I have
created within my COM Server. To do this I pass the HWND as an integer
to the service which then passes it to the win32 binary.
I am aware that because I am on a different window station that does
not interact with the desktop I have to set up the lpDesktop in
STARTUPINFO.
I do pass my window station plus the default desktop to the service to
pass to the windows binary. Some of the service code looks something
like this:

// start the scanner engine
STARTUPINFO si;
memset(&si, 0, sizeof(STARTUPINFO));

memset(&pi, 0, sizeof(PROCESS_INFORMATION));

si.cb = sizeof(STARTUPINFO);
si.lpReserved = NULL;
si.lpTitle = NULL;
si.dwFlags = NULL;
si.wShowWindow = NULL;
si.lpReserved2 = NULL;
si.cbReserved2 = 0;
si.lpDesktop = (LPSTR)lpszDesktop; // the desktop is my
// windowstation/default desktop

// lpszCmdLine is something like test.exe 1234 (1234 being the HWND)
if(CreateProcess(NULL, (LPTSTR)(LPCTSTR)lpszCmdLine, NULL, NULL,
/*FALSE*/TRUE,
CREATE_SUSPENDED | CREATE_NO_WINDOW, NULL, _T("C:\\"), &si, &pi))
{

*pdwID = pi.dwProcessId;
m_hHandle = pi.hProcess;

// start the scanner thread
ResumeThread(pi.hThread);

This is my problem... For some reason as soon as I resume the thread
the binary exits. I don't know why. I have tried to move the
CreateProcess for trial purposes to the original COM Server. It does
enter into the binary and does not exit but, I'm not sure I'm
recieving messages from the win32 binary, which is the whole purpose
that I'm passing a handle.

If anyone could help that would be great!

-S