之前都很顺利,稳稳地,根据msdn的文档简单修改就可以了。
Windows客户端开发–使用WMI获取显卡详细信息(win32控制台程序)
但是,可但是,当我们把wmi用于qt中时,一个接一个的坑儿就来了。
CoInitializeEx
在GUI程序中,不再是这样:
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
改成
hres = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
MFC中存在类似的问题:
An MFC application uses a lot of thread local storage to store thread state information and to process state information. Therefore, an MFC application is not compatible