Ausgabe von externem Programm in Datei umleiten
-
ich habe mir das bcb example wintool angeschaut, weil ich die ausgabe von einem ausgeführten programm in eine datei speichern möchte. dort steht dann irgendwas von pipes und bla... ich steig da einfach nicht durch... könnte das mal jemand für mich auf das wesentliche beschränken? wenn ich das einfach über system() mache kann ich ja >> verwenden, und dann haben ich aber immer so ein sch... dos-fenster, was ich zu verhindern versuche... thx
-
Wenn ich dich richtig verstanden habe, suchst du das hier: Creating a Child Process with Redirected Input and Output, oder?!

-
also ich habe jetzt einen code geschrieben, der funktioniert auch recht gut, aber der haut so ca. in jeder 216. Zeile 2 Müllzeichen rein

weiß jemand woran das liegen könnte?SECURITY_DESCRIPTOR sd; SECURITY_ATTRIBUTES sa; LPSECURITY_ATTRIBUTES lpsa = NULL; if (IsWindowsNT()) { InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(&sd, true, NULL, false); sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = true; sa.lpSecurityDescriptor = &sd; lpsa = &sa; } HANDLE hReadPipe; HANDLE hWritePipe; assert(CreatePipe(&hReadPipe, &hWritePipe, lpsa, 2500000)); STARTUPINFO si; memset(&si, 0, sizeof(STARTUPINFO)); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESHOWWINDOW |STARTF_USESTDHANDLES; si.wShowWindow = SW_HIDE; si.hStdOutput = hWritePipe; si.hStdError = hWritePipe; PROCESS_INFORMATION pi; assert(hWritePipe); if(CreateProcess(NULL, (file+" "+para).c_str(), NULL, NULL, TRUE, 0, 0, 0, &si, &pi)) { CloseHandle(pi.hThread); WaitForSingleObject(pi.hProcess, 90000); // read from the pipe and put in richedit assert(hReadPipe); DWORD BytesRead; //unsigned long char dest[4000]; bool RdLoopDone = false; ResultsRE->Lines->Clear(); int FBreak = 1; while (!RdLoopDone) { memset(dest, 0, 4000); assert(ReadFile(hReadPipe, &dest, sizeof(dest), &BytesRead, NULL)); ResultsRE->Lines->Add(String(dest)); if (BytesRead < 4000) { RdLoopDone = true; } if (FBreak > 150) { RdLoopDone = true; } FBreak++; } } ResultsRE->Lines->SaveToFile(open);