主题:VC++6.0 调用WMI
HRESULT hr= CoInitializeEx(0,COINIT_MULTITHREADED);
if (FAILED(hr))
{
return ;
}
//用CoInitializeSecurity函数注册并设置进程的默认的安全值:
hr= CoInitializeSecurity(
NULL, // Security descriptor
-1, // COM negotiates authentication service
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication level for proxies
RPC_C_IMP_LEVEL_IMPERSONATE,// Default Impersonation level for proxies
NULL, // Authentication info
EOAC_NONE, // Additional capabilities of the client or server
NULL); // Reserved
//用CoCreateInstance函数来初始化IwbemLocator接口
IWbemLocator *pLoc = 0;
hr = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID *) &pLoc
);
网上参考了如上代码,但是在CLSID_WbemLocator却出现错误
error LNK2001: unresolved external symbol _CLSID_WbemLocator
该怎么办,谁教教我。
if (FAILED(hr))
{
return ;
}
//用CoInitializeSecurity函数注册并设置进程的默认的安全值:
hr= CoInitializeSecurity(
NULL, // Security descriptor
-1, // COM negotiates authentication service
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication level for proxies
RPC_C_IMP_LEVEL_IMPERSONATE,// Default Impersonation level for proxies
NULL, // Authentication info
EOAC_NONE, // Additional capabilities of the client or server
NULL); // Reserved
//用CoCreateInstance函数来初始化IwbemLocator接口
IWbemLocator *pLoc = 0;
hr = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator,
(LPVOID *) &pLoc
);
网上参考了如上代码,但是在CLSID_WbemLocator却出现错误
error LNK2001: unresolved external symbol _CLSID_WbemLocator
该怎么办,谁教教我。