-1
好的這裏是我想要調用在\ windows \ system32 \ wbem中找到的wmic.exe的問題執行一個命令,並只讀取那裏的輸出。從wmic控制檯應用程序中讀取輸出
我不希望使用wmi使用com按照msdn(http://msdn.microsoft.com/en-us/library/aa390423(v=vs.85).aspx),我不想通過cmd執行wmic。
,我不能得到使它幹活閱讀這個線程太的方式,但沒有人回答non-trivial use of `Console` by `wmic.exe`
我已經試過這樣的事情:
FILE* pipe = _popen("wmic.exe cpu get", "r");
if (!pipe)
throw std::exception("error");
char buffer[128];
std::string output;
while(!feof(pipe))
{
if(fgets(buffer, 128, pipe) != NULL) output += buffer;
}
_pclose(pipe);
std::stringstream oss(output);
std::vector<std::string> processor_description;
std::string buffer;
while (std::getline(oss, buffer))
processor_description.push_back(buffer);
我嘗試過使用管道(_popen和_pclose) – juniorcoder 2014-09-24 14:47:48
我已經在問題中粘貼了你的源代碼,請自己下次再下載 – duDE 2014-09-24 14:51:26
好吧,對不起!關於我的概率的任何想法? <: – juniorcoder 2014-09-24 14:52:04