w***@gmail.com
2008-12-02 03:10:36 UTC
Hi,
everyone. In order to update automatically my application, I
invented a "shell" auxiliary application. This shell will perform
updating each time the user click the shortcut from desktop which,in
fact, launch the shell. After updating, the shell would call
CreateProcess to spawn the actual Application, the code is as follows:
void RunProcess(stringT& appName)
{ //appName is the application name
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess( const_cast<TCHAR*>(appName.c_str()), NULL,
NULL, NULL,FALSE, 0, NULL, NULL,&si, &pi ))
{
MessageBox(NULL,_T("Can't Creation Process"),_T("Error"),MB_OK);
}
}
The shell will exit as soon as calling Runprocess. Then the problem
comes out:that createprocess does not create a process. I thought
there must have some exception. Therefore, I placed a try-catch
structure in the shell's _tWinMain function. The catch clause does
really take effect. The curious thing is: sometimes the shell can
spawn the application without any exception.
Now,my questions are: why the CreateProcess fail to work? Moreover,
why it sometimes works?
I'll appreciate your help.
Looking forward to your response.
everyone. In order to update automatically my application, I
invented a "shell" auxiliary application. This shell will perform
updating each time the user click the shortcut from desktop which,in
fact, launch the shell. After updating, the shell would call
CreateProcess to spawn the actual Application, the code is as follows:
void RunProcess(stringT& appName)
{ //appName is the application name
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if( !CreateProcess( const_cast<TCHAR*>(appName.c_str()), NULL,
NULL, NULL,FALSE, 0, NULL, NULL,&si, &pi ))
{
MessageBox(NULL,_T("Can't Creation Process"),_T("Error"),MB_OK);
}
}
The shell will exit as soon as calling Runprocess. Then the problem
comes out:that createprocess does not create a process. I thought
there must have some exception. Therefore, I placed a try-catch
structure in the shell's _tWinMain function. The catch clause does
really take effect. The curious thing is: sometimes the shell can
spawn the application without any exception.
Now,my questions are: why the CreateProcess fail to work? Moreover,
why it sometimes works?
I'll appreciate your help.
Looking forward to your response.