CreateProcess() probelms [modified]
-
the code im about to put down.. seems to run through without errors... however. when i cout out the final conversion i get wierd numbers... but basically what i have here is create process.. im using a dummy.exe to create a txt file so i know if it works right away... if(first4=="EXEC"){ LPWSTR szCmdline=(LPWSTR)cl.c_str(); STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; HANDLE hPipeRead, hpRead; HANDLE hPipeWrite; SECURITY_ATTRIBUTES sa; memset(&ProcessInformation,0,sizeof(ProcessInformation)); memset(&sa,0,sizeof(sa)); sa.nLength=sizeof(sa); sa.bInheritHandle = TRUE; CreatePipe(&hPipeRead,&hPipeWrite,&sa,0); memset(&StartupInfo,0,sizeof(StartupInfo)); cout << "pipes and memset"; GetStartupInfo(&StartupInfo); StartupInfo.hStdOutput = hPipeWrite; StartupInfo.hStdInput = hPipeRead; StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; cout << "StartupInfo Read\n"; CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); cout << szCmdline; CloseHandle( hPipeWrite ); Sleep(100); DWORD stuff; char buff[1000]; bool firstsend; int offset = 0, bRecv; PeekNamedPipe(hPipeRead, NULL, 0, NULL, &stuff, NULL); if(stuff != 0) { ZeroMemory(buff, sizeof(buff)); firstsend = true; do { ReadFile(hPipeRead, buff, 1000, &stuff, NULL); if(firstsend) { send(usersock, buff + offset, strlen(buff) - offset, 0); firstsend = false; } else send(usersock, buff, strlen(buff), 0); } while(stuff == 1000); } else { char ccc[128]="NoReply program run"; send(usersock, ccc, strlen(ccc), 0); } } // // This is for an ftp server and webserver i have to get this create process functioning and outputing // the dos screen info through a socket which i already have setup here and should work.... but errors // out when if statement is called... ive been playing wiht it for about 2hr... plz help // im using Visual Studio 2005 C++ and im pretty sure this is CLR -- modified at 7:22 Monday 5th March, 2007
-
the code im about to put down.. seems to run through without errors... however. when i cout out the final conversion i get wierd numbers... but basically what i have here is create process.. im using a dummy.exe to create a txt file so i know if it works right away... if(first4=="EXEC"){ LPWSTR szCmdline=(LPWSTR)cl.c_str(); STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInformation; HANDLE hPipeRead, hpRead; HANDLE hPipeWrite; SECURITY_ATTRIBUTES sa; memset(&ProcessInformation,0,sizeof(ProcessInformation)); memset(&sa,0,sizeof(sa)); sa.nLength=sizeof(sa); sa.bInheritHandle = TRUE; CreatePipe(&hPipeRead,&hPipeWrite,&sa,0); memset(&StartupInfo,0,sizeof(StartupInfo)); cout << "pipes and memset"; GetStartupInfo(&StartupInfo); StartupInfo.hStdOutput = hPipeWrite; StartupInfo.hStdInput = hPipeRead; StartupInfo.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; StartupInfo.wShowWindow = SW_HIDE; cout << "StartupInfo Read\n"; CreateProcess(NULL, szCmdline, NULL, NULL, TRUE, 0, NULL, NULL, &StartupInfo, &ProcessInformation); cout << szCmdline; CloseHandle( hPipeWrite ); Sleep(100); DWORD stuff; char buff[1000]; bool firstsend; int offset = 0, bRecv; PeekNamedPipe(hPipeRead, NULL, 0, NULL, &stuff, NULL); if(stuff != 0) { ZeroMemory(buff, sizeof(buff)); firstsend = true; do { ReadFile(hPipeRead, buff, 1000, &stuff, NULL); if(firstsend) { send(usersock, buff + offset, strlen(buff) - offset, 0); firstsend = false; } else send(usersock, buff, strlen(buff), 0); } while(stuff == 1000); } else { char ccc[128]="NoReply program run"; send(usersock, ccc, strlen(ccc), 0); } } // // This is for an ftp server and webserver i have to get this create process functioning and outputing // the dos screen info through a socket which i already have setup here and should work.... but errors // out when if statement is called... ive been playing wiht it for about 2hr... plz help // im using Visual Studio 2005 C++ and im pretty sure this is CLR -- modified at 7:22 Monday 5th March, 2007
- read the Forum Guidelines[^] first (especially 1. and 5. in your case) 2) your answer is here[^]
[VisualCalc][Binary Guide updated! ][CommDialogs new! ] | [Forums Guidelines]