Answer to Question #249143 in Java | JSP | JSF for hatipo

Question #249143

// 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; }


1
Expert's answer
2021-10-10T13:23:14-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS