salut javai fait un peti program de la sorte pour afficher les resulta dun process dufférent du mien
DWORD fport() { LPTSTR lpCommandLine = "OpPorts.exe"; HANDLE hReadPipe, hWritePipe ; HANDLE hErrReadPipe, hErrWritePipe;
DWORD dwStdOut;
DWORD dwRet; DWORD res;
SECURITY_ATTRIBUTES sa; STARTUPINFO StartupInfo; PROCESS_INFORMATION ProcessInfo;
sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE;
hReadPipe = NULL; hWritePipe = NULL; hErrReadPipe = NULL; hErrWritePipe = NULL; dwStdOut = 0;
CreatePipe(&hReadPipe, &hWritePipe, &sa, 8192);
ZeroMemory(&StartupInfo, sizeof(STARTUPINFO));
StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.dwFlags = STARTF_USESTDHANDLES; StartupInfo.wShowWindow = SW_HIDE; StartupInfo.hStdOutput = hWritePipe;
if (CreateProcess( NULL, lpCommandLine, &sa, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &StartupInfo, &ProcessInfo)) {
while ( (dwRet = WaitForSingleObject(ProcessInfo.hProcess, 2000)) != WAIT_ABANDONED) { memset(bufStdOut, 0, sizeof(bufStdOut));
ReadFile(hReadPipe, bufStdOut, sizeof(bufStdOut) - 1, &dwStdOut,NULL); if (dwRet == WAIT_OBJECT_0) break; }
GetExitCodeProcess(ProcessInfo.hProcess, &res); CloseHandle(ProcessInfo.hProcess); CloseHandle(ProcessInfo.hThread); } else {
printf( "CreateProcess failed %s\n",lpCommandLine );
}
CloseHandle(hWritePipe); CloseHandle(hReadPipe); CloseHandle(hErrWritePipe); CloseHandle(hErrReadPipe);
return 0; }
je me rappel plus si ya des erreur enfin cest basé sur un exemple de msdn... a+
|