V
Vegan Fanatic
Guest
so far I have this:
HRESULT getMBstring(void) {
HRESULT hr;
hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hr)) {
std::cout << "Failed to initialize COM library. Error code = 0x" << std::hex << hr << std::endl;
return hr;
}
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
if (FAILED(hr)) {
std::cout << "Failed to initialize security. Error code = 0x" << std::hex << hr << std::endl;
CoUninitialize();
return hr; // Program has failed.
}
IWbemLocator *pLoc = 0;
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hr)) {
std::cout << "Failed to create IWbemLocator object. Err code = 0x" << std::hex << hr << std::endl;
CoUninitialize();
return hr; // Program has failed.
}
IWbemServices *pSvc = 0;
// Connect to the root\default namespace with the current user.
hr = pLoc->ConnectServer(BSTR(L"ROOT\\DEFAULT"), NULL, NULL, 0, NULL, 0, 0, &pSvc);
if (FAILED(hr)) {
std::cout << "Could not connect. Error code = 0x" << std::hex << hr << std::endl;
pLoc->Release();
CoUninitialize();
return hr; // Program has failed.
}
std::cout << "Connected to WMI" << std::endl;
}
The manual: http://msdn.microsoft.com/en-us/library/aa394072(VS.85).aspx
Trying to retrieve the manufacturer and model fields
I have other code to identify the CPU and RAM and clock speed, but those came from registry calls. This WMI is not something I have much experience with.
Corsair Carbide 300R with window & Corsair TX850V2 70A@12V
Asus M5A99FX PRO R2.0 CFX/SLI & AMD Phenom II 965 C3 Black Edition @ 4.0 GHz & G.SKILL RipjawsX DDR3-2133 8 GB
GTX 260 SLI 216 core (GT200 Tesla) & Asus PA238QR IPS LED HDMI DP 1080p
ST2000DM001 & Windows 7 x64 Enterprise
Microsoft Wireless Desktop 2000 & Wacom Bamboo CHT470M
Place your rig specifics into your signature like I have, makes it 100x easier to understand!
Hardcore Games, Legendary is the Only Way to Play
Continue reading...
HRESULT getMBstring(void) {
HRESULT hr;
hr = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hr)) {
std::cout << "Failed to initialize COM library. Error code = 0x" << std::hex << hr << std::endl;
return hr;
}
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
if (FAILED(hr)) {
std::cout << "Failed to initialize security. Error code = 0x" << std::hex << hr << std::endl;
CoUninitialize();
return hr; // Program has failed.
}
IWbemLocator *pLoc = 0;
hr = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
if (FAILED(hr)) {
std::cout << "Failed to create IWbemLocator object. Err code = 0x" << std::hex << hr << std::endl;
CoUninitialize();
return hr; // Program has failed.
}
IWbemServices *pSvc = 0;
// Connect to the root\default namespace with the current user.
hr = pLoc->ConnectServer(BSTR(L"ROOT\\DEFAULT"), NULL, NULL, 0, NULL, 0, 0, &pSvc);
if (FAILED(hr)) {
std::cout << "Could not connect. Error code = 0x" << std::hex << hr << std::endl;
pLoc->Release();
CoUninitialize();
return hr; // Program has failed.
}
std::cout << "Connected to WMI" << std::endl;
}
The manual: http://msdn.microsoft.com/en-us/library/aa394072(VS.85).aspx
Trying to retrieve the manufacturer and model fields
I have other code to identify the CPU and RAM and clock speed, but those came from registry calls. This WMI is not something I have much experience with.
Corsair Carbide 300R with window & Corsair TX850V2 70A@12V
Asus M5A99FX PRO R2.0 CFX/SLI & AMD Phenom II 965 C3 Black Edition @ 4.0 GHz & G.SKILL RipjawsX DDR3-2133 8 GB
GTX 260 SLI 216 core (GT200 Tesla) & Asus PA238QR IPS LED HDMI DP 1080p
ST2000DM001 & Windows 7 x64 Enterprise
Microsoft Wireless Desktop 2000 & Wacom Bamboo CHT470M
Place your rig specifics into your signature like I have, makes it 100x easier to understand!
Hardcore Games, Legendary is the Only Way to Play
Continue reading...