K
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);