-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