
bool OnShellCall(const char *shell_cmd, CString& result) { FILE* pipe = ::popen(shell_cmd, "r"); if (!pipe) { return false; } char buffer[256] = {0}; result = ""; char * s_read = NULL; while(!feof(pipe)) { //s_read return null 或读取完毕 s_read = fgets(buffer, sizeof(buffer), pipe); if (NULL!=s_read) { result += buffer; } else { break; } } pclose(pipe); s_read = NULL; return TRUE; }