(WinAPI) pipes...
-
Hi,
vorweg entschuldige ich mich schonmal sollte es das falsche Forum sein, da ich mir absolut end sicher war...
Also ich hatte nach ner Möglichkeit gesucht, wie man Befehle an ein anderes Programm geben kann, hier gesucht und auf Pipes gestoßen, so nachdem ich nun mein Programm soweit fertig hab, dass es läuft und die pipe auch zu funktionieren scheint, aber das andere Programm (cmd.exe) ned reagiert auf den Befehl frag ich mich, ob ich es grundsätzlihc falsch angestellt hab, oder ob man irgendne Zeichenfolge oder sowat braucht, die wie <enter> wirkt??
Hier mein source:HANDLE hInputWrite = NULL; HANDLE hInputRead = NULL; HANDLE hError = NULL; SECURITY_ATTRIBUTES sa = {0}; PROCESS_INFORMATION pi = {0}; STARTUPINFO si ={0}; CHAR lpInput[10] = {'N','E','T',' ','U','S','E',' ','/','?'}; CHAR lpOutput[200] = {0}; DWORD nBytesWritten= 0; DWORD nBytesRead = 0; sa.nLength= sizeof(SECURITY_ATTRIBUTES); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; LPTSTR lpszApplication = "cmd.exe"; LPTSTR lpszTitle="7357"; CreatePipe(&hInputRead, &hInputWrite, &sa, 0); si.cb = sizeof(STARTUPINFO); si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; si.lpTitle = lpszTitle; si.hStdOutput = hInputRead; si.hStdInput = hInputWrite; si.hStdError = hError; si.wShowWindow = SW_SHOW; CreateProcess(NULL,lpszApplication , NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL ,NULL, &si, &pi); WaitForInputIdle(pi.hProcess, 1000); WriteFile(hInputWrite, lpInput, 10, &nBytesWritten, NULL); lpInput[nBytesWritten] = '\0'; ReadFile(hInputRead, lpOutput, 255, &nBytesRead, NULL); lpOutput[nBytesRead] = '\0'; CListBox* pListBox= (CListBox*) GetDlgItem(IDC_LIST1); pListBox->AddString(lpOutput); CloseHandle(pi.hThread); CloseHandle(hInputRead); CloseHandle(hInputWrite);Hoff mal ihr lacht mich ned aus, wegen dem Code.
greetz
Oss
-
Also
1.
Es IST das falsche Forum!
->Ein Prof. von mir sagte immer: 'Wenn jemand die Chance hat, zwischen 2 Möglichkeiten zu wählen, nimmt er die Falsche. q.e.d.Pipes sind eine sehr spezifische Möglichkeit, eine Software fernzusteuern. Und wenn diese Software das nicht unterstützt, kann Dein Code so gut sein wie er will, er wird nie funzen.
P.S. So gut wie keine Software unterstützt diese Möglichkeit.
Für Diskussion darüber, welche Möglichkeiten es gibt, schiebe ich das Ganze ins WinAPI-Forum!