// build and run this example #include #include #include int main(void) { BOOL bRet; STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si,sizeof(si)); si.cb=sizeof(si); ZeroMemory(&pi,sizeof(pi)); bRet=CreateProcess(NULL,"notepad.exe",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi); if(bRet==FALSE) { printf("Error: %u\n",GetLastError()); return 1; } CloseHandle(pi.hProcess); CloseHandle(pi.hThread); // close handles to kernel objs return 0; }
#include <stdio.h>
#include <windows.h>
int main(void)
{
BOOL bRet;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
bRet=CreateProcess(NULL,"notepad.exe",NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
if( !CreateProcess( "notepad.exe",
NULL,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi ) )
{
puts("Error"); //f(bRet==FALSE) { printf("Error:
return 0;
}
WaitForSingleObject( pi.hProcess, INFINITE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );// close handles to kernel objs return 0;
}
Comments
Leave a comment