C
|
C++
|
Objective-C
|
VC++
|
Win32
|
MFC
|
Java
|
Php
|
Delphi
|
Visual Basic
|
.Net
|
Networking
|
General
|
Games
|
Jobs
|
Javascript
|
Menu
Project Upload
Project Download
Articles
Programs
Search
Solution
pickSourcecode.com
Login
Register
About us
Contact us
VCpp
>
Programs
vcpp - CreateProcess sample ( child process )
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
void
_tmain(
int
argc, TCHAR *argv[] )
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char
cmdLineArgs_Uninstall[1024];
char
szSetUpISS_Uninstall[1024], szSetUpEXE_Uninstall[1024], szMachineName[1024];
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
strcpy(szSetUpISS_Uninstall,"C:\\SBP_Temp\\IU_setup_uninstall.iss");
strcpy(szSetUpEXE_Uninstall, "C:\\Program Files\\Skill Building Pro\\Setup.exe");
strcpy(szMachineName, "MALATHI_V");
// sprintf(cmdLineArgs_Uninstall, "C:\\psexec.exe \\\\MALATHI_V ""\"C:\\SBPFiles\\setup.exe\" -s -f1""\"C:\\SBP_Temp\\IU_setup_uninstall.iss\"");
sprintf(cmdLineArgs_Uninstall, "psexec.exe \\\\%s ""\"%s\" -s -f1""\"%s\"", szMachineName, szSetUpEXE_Uninstall, szSetUpISS_Uninstall );
// Start the child process.
if
( !CreateProcess( NULL,
// No module name (use command line)
cmdLineArgs_Uninstall,
// Command line
NULL,
// Process handle not inheritable
NULL,
// Thread handle not inheritable
FALSE,
// Set handle inheritance to FALSE
0,
// No creation flags
NULL,
// Use parent's environment block
NULL,
// Use parent's starting directory
&si,
// Pointer to STARTUPINFO structure
&pi )
// Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
DWORD dwError = WaitForInputIdle( pi.hProcess, INFINITE);
DWORD dwExitCode;
while( 1 )
{
dwExitCode = 0;
GetExitCodeProcess( pi.hProcess, &dwExitCode );
if
( dwExitCode != 259 )
{
break;
}
else
{
::Sleep(5000);
}
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
Privacy Policy
|
About Us