user-0 提问: ------------------------------------求指点一个思路------------------------------------

回复:
user: user-0
content: 我自己顶下了

user: user-0
content: 输出到文件 再读取 没别的方法了

user: user-1
content: 引用 11 楼 zhao4zhong1 的回复:[quote=引用 10 楼 zhao4zhong1 的回复:] Hook INT10H 这是纯DOS下的思路。  Windows下参考下面： #pragma comment(lib,"user32") #include <stdio.h> #include <windows.h> int main() {     SECURITY_ATTRIBUTES sa          = {0};     STARTUPINFO         si          = {0};     PROCESS_INFORMATION pi          = {0};     HANDLE              hPipeOutputRead  = NULL;     HANDLE              hPipeOutputWrite = NULL;     HANDLE              hPipeInputRead   = NULL;     HANDLE              hPipeInputWrite  = NULL;     BOOL                bTest = 0;     DWORD               dwNumberOfBytesRead = 0;     DWORD               dwNumberOfBytesWrite = 0;     CHAR                szMsg[100];     CHAR                szBuffer[256];      sa.nLength = sizeof(sa);     sa.bInheritHandle = TRUE;     sa.lpSecurityDescriptor = NULL;      // Create pipe for standard output redirection.     CreatePipe(&hPipeOutputRead,  // read handle             &hPipeOutputWrite, // write handle             &sa,      // security attributes             0      // number of bytes reserved for pipe - 0 default             );      // Create pipe for standard input redirection.     CreatePipe(&hPipeInputRead,  // read handle             &hPipeInputWrite, // write handle             &sa,      // security attributes             0      // number of bytes reserved for pipe - 0 default             );      // Make child process use hPipeOutputWrite as standard out,     // and make sure it does not show on screen.     si.cb = sizeof(si);     si.dwFlags     = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;     si.wShowWindow = SW_HIDE;     si.hStdInput   = hPipeInputRead;     si.hStdOutput  = hPipeOutputWrite;     si.hStdError   = hPipeOutputWrite;      CreateProcess (           NULL, "cmd.exe",           NULL, NULL,           TRUE, 0,           NULL, NULL,           &si, &pi);      // Now that handles have been inherited, close it to be safe.     // You don't want to read or write to them accidentally.     CloseHandle(hPipeOutputWrite);     CloseHandle(hPipeInputRead);      // Now test to capture DOS application output by reading     // hPipeOutputRead.  Could also write to DOS application     // standard input by writing to hPipeInputWrite.     sprintf(szMsg, "dir *.txt /b\nexit\n");     WriteFile(           hPipeInputWrite,      // handle of the write end of our pipe           &szMsg,               // address of buffer that send data           18,                   // number of bytes to write           &dwNumberOfBytesWrite,// address of number of bytes read           NULL                  // non-overlapped.           );      while(TRUE)     {        bTest=ReadFile(           hPipeOutputRead,      // handle of the read end of our pipe           &szBuffer,            // address of buffer that receives data           256,                  // number of bytes to read           &dwNumberOfBytesRead, // address of number of bytes read           NULL                  // non-overlapped.           );        if (!bTest){           sprintf(szMsg, "Error #%d reading pipe.",GetLastError());           MessageBox(NULL, szMsg, "WinPipe", MB_OK);           break;       }        // do something with data.       szBuffer[dwNumberOfBytesRead] = 0;  // null terminate       MessageBox(NULL, szBuffer, "WinPipe", MB_OK);     }      // Wait for CONSPAWN to finish.     WaitForSingleObject (pi.hProcess, INFINITE);      // Close all remaining handles     CloseHandle (pi.hProcess);     CloseHandle (hPipeOutputRead);     CloseHandle (hPipeInputWrite);      return 0; } [/quote]不明觉厉

user: user-2
content: 引用 10 楼 zhao4zhong1 的回复:Hook INT10H 这是纯DOS下的思路。  Windows下参考下面： #pragma comment(lib,"user32") #include <stdio.h> #include <windows.h> int main() {     SECURITY_ATTRIBUTES sa          = {0};     STARTUPINFO         si          = {0};     PROCESS_INFORMATION pi          = {0};     HANDLE              hPipeOutputRead  = NULL;     HANDLE              hPipeOutputWrite = NULL;     HANDLE              hPipeInputRead   = NULL;     HANDLE              hPipeInputWrite  = NULL;     BOOL                bTest = 0;     DWORD               dwNumberOfBytesRead = 0;     DWORD               dwNumberOfBytesWrite = 0;     CHAR                szMsg[100];     CHAR                szBuffer[256];      sa.nLength = sizeof(sa);     sa.bInheritHandle = TRUE;     sa.lpSecurityDescriptor = NULL;      // Create pipe for standard output redirection.     CreatePipe(&hPipeOutputRead,  // read handle             &hPipeOutputWrite, // write handle             &sa,      // security attributes             0      // number of bytes reserved for pipe - 0 default             );      // Create pipe for standard input redirection.     CreatePipe(&hPipeInputRead,  // read handle             &hPipeInputWrite, // write handle             &sa,      // security attributes             0      // number of bytes reserved for pipe - 0 default             );      // Make child process use hPipeOutputWrite as standard out,     // and make sure it does not show on screen.     si.cb = sizeof(si);     si.dwFlags     = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;     si.wShowWindow = SW_HIDE;     si.hStdInput   = hPipeInputRead;     si.hStdOutput  = hPipeOutputWrite;     si.hStdError   = hPipeOutputWrite;      CreateProcess (           NULL, "cmd.exe",           NULL, NULL,           TRUE, 0,           NULL, NULL,           &si, &pi);      // Now that handles have been inherited, close it to be safe.     // You don't want to read or write to them accidentally.     CloseHandle(hPipeOutputWrite);     CloseHandle(hPipeInputRead);      // Now test to capture DOS application output by reading     // hPipeOutputRead.  Could also write to DOS application     // standard input by writing to hPipeInputWrite.     sprintf(szMsg, "dir *.txt /b\nexit\n");     WriteFile(           hPipeInputWrite,      // handle of the write end of our pipe           &szMsg,               // address of buffer that send data           18,                   // number of bytes to write           &dwNumberOfBytesWrite,// address of number of bytes read           NULL                  // non-overlapped.           );      while(TRUE)     {        bTest=ReadFile(           hPipeOutputRead,      // handle of the read end of our pipe           &szBuffer,            // address of buffer that receives data           256,                  // number of bytes to read           &dwNumberOfBytesRead, // address of number of bytes read           NULL                  // non-overlapped.           );        if (!bTest){           sprintf(szMsg, "Error #%d reading pipe.",GetLastError());           MessageBox(NULL, szMsg, "WinPipe", MB_OK);           break;       }        // do something with data.       szBuffer[dwNumberOfBytesRead] = 0;  // null terminate       MessageBox(NULL, szBuffer, "WinPipe", MB_OK);     }      // Wait for CONSPAWN to finish.     WaitForSingleObject (pi.hProcess, INFINITE);      // Close all remaining handles     CloseHandle (pi.hProcess);     CloseHandle (hPipeOutputRead);     CloseHandle (hPipeInputWrite);      return 0; }

user: user-2
content: Hook INT10H

user: user-0
content: 谢谢楼上了 我试试啊

user: user-3
content: 给你查了一下： 在启动cmd时，用如下的命令： cmd /k "mode 50,10" 或者启动cmd后用mode 50,10设置一下 此时缓冲区只有250个字符，之后用管道试一下。如果250个字符你还不认为是实时，那我这里没啥好办法了...

user: user-0
content: 不想输出到文件 能不能直接在内存里面处理  搜到用管道  继续求思路中.......

user: user-4
content: 引用 1 楼 user-6 的回复:试试重定向，再过滤  楼主要可以试下重定向。将程序输出到一个文件处理。

user: user-3
content: 回复#4楼： 我的理解是：不会等程序完全输出完了你的程序再处理。程序一般有个buffer，buffer满了之后再输出到屏幕上。如果你输出的信息足够多，不用担心这个问题吧。

user: user-0
content: 2楼 liweiiewil  你这方法可以是可以 就是要等别的程序完全输出完了 我的程序才能再去处理 不能实时

user: user-5
content: 挺有挑战性的 等大家分享吧。。

user: user-3
content: 它会输出到哪呢? 如果输出到屏幕上，那么就可以用管道的方法作为你的文件的输入。比如这个程序叫c:\a.exe，那么可以这么写：  c:\a.exe | b.exe  b.exe是你写的程序，在其内部可以用cin获取a.exe的输出，进行过滤后再输出即可。

user: user-6
content: 试试重定向，再过滤