|
|
|
|
@ -125,34 +125,34 @@ void lpHardwareInfo::deviceQuery()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//CPU ID
|
|
|
|
|
CHAR* szSelect = "SELECT * FROM Win32_Processor WHERE (ProcessorId IS NOT NULL)";
|
|
|
|
|
WCHAR* szProperty = L"ProcessorId";
|
|
|
|
|
CHAR* szSelect = charReCHAR("SELECT * FROM Win32_Processor WHERE (ProcessorId IS NOT NULL)");
|
|
|
|
|
WCHAR* szProperty = charReWCHAR("ProcessorId");
|
|
|
|
|
deviceQuery(szSelect, szProperty, msCpuID);
|
|
|
|
|
|
|
|
|
|
//MotherBoard ID
|
|
|
|
|
szSelect = "SELECT * FROM Win32_BaseBoard WHERE (SerialNumber IS NOT NULL)";
|
|
|
|
|
szProperty = L"SerialNumber";
|
|
|
|
|
szSelect = charReCHAR("SELECT * FROM Win32_BaseBoard WHERE(SerialNumber IS NOT NULL)");
|
|
|
|
|
szProperty = charReWCHAR("SerialNumber");
|
|
|
|
|
deviceQuery(szSelect, szProperty, msMotherBoardID);
|
|
|
|
|
|
|
|
|
|
//BIOS ID
|
|
|
|
|
szSelect = "SELECT * FROM Win32_BIOS WHERE (SerialNumber IS NOT NULL)";
|
|
|
|
|
szProperty = L"SerialNumber";
|
|
|
|
|
szSelect = charReCHAR("SELECT * FROM Win32_BIOS WHERE (SerialNumber IS NOT NULL)");
|
|
|
|
|
szProperty = charReWCHAR("SerialNumber");
|
|
|
|
|
deviceQuery(szSelect, szProperty, msBiosID);
|
|
|
|
|
|
|
|
|
|
//MAC Address only Physical and not [virtual, vpn, usb, ...]
|
|
|
|
|
msMacAddress = "";
|
|
|
|
|
//szSelect = "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = true \
|
|
|
|
|
//szSelect = charReCHAR("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = true \
|
|
|
|
|
// and NOT Name LIKE '%vpn%' and NOT Name LIKE '%virtual%' \
|
|
|
|
|
// and NOT Name LIKE '%usb%' and NOT Name LIKE '%Bluetooth%'";
|
|
|
|
|
szSelect = "SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = true \
|
|
|
|
|
and ( Name LIKE '%pci%' or PNPDeviceID LIKE '%pci%')";
|
|
|
|
|
szProperty = L"MACAddress";
|
|
|
|
|
szSelect = charReCHAR("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = true \
|
|
|
|
|
and ( Name LIKE '%pci%' or PNPDeviceID LIKE '%pci%')");
|
|
|
|
|
szProperty = charReWCHAR("MACAddress");
|
|
|
|
|
deviceQuery(szSelect, szProperty, msMacAddress);
|
|
|
|
|
|
|
|
|
|
//hard disk only "Fixed hard disk media"
|
|
|
|
|
msHardDrive = "";
|
|
|
|
|
szSelect = "SELECT * FROM Win32_DiskDrive WHERE MediaType LIKE '%Fixed%'";
|
|
|
|
|
szProperty = L"SerialNumber";
|
|
|
|
|
szSelect = charReCHAR("SELECT * FROM Wi(n32_DiskDrive WHERE MediaType LIKE '%Fixed%'");
|
|
|
|
|
szProperty = charReWCHAR("SerialNumber");
|
|
|
|
|
deviceQuery(szSelect, szProperty, msHardDrive);
|
|
|
|
|
|
|
|
|
|
//Desktop or laptop
|
|
|
|
|
@ -165,7 +165,7 @@ void lpHardwareInfo::deviceQuery(CHAR* szSelect, WCHAR* szProperty, std::string&
|
|
|
|
|
DEVICE_PROPERTY dpRst;
|
|
|
|
|
|
|
|
|
|
// TCHAT to std::string
|
|
|
|
|
auto tc2string = [&](TCHAR* ts) -> std::string {
|
|
|
|
|
auto tc2string = [&](TCHAR* ts) -> std::string& {
|
|
|
|
|
int iLen = WideCharToMultiByte(CP_ACP, 0, ts, -1, NULL, 0, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
char* chRtn = new char[iLen * sizeof(char)];
|
|
|
|
|
@ -229,14 +229,26 @@ void lpHardwareInfo::deviceQuery(CHAR* szSelect, WCHAR* szProperty, std::string&
|
|
|
|
|
strRslt.erase(strRslt.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CHAR * lpHardwareInfo::charReCHAR(const char myString[]) {
|
|
|
|
|
CHAR myCharString[100];
|
|
|
|
|
strcpy(myCharString, myString);
|
|
|
|
|
return myCharString;
|
|
|
|
|
}
|
|
|
|
|
WCHAR* lpHardwareInfo::charReWCHAR(const char myString[]) {
|
|
|
|
|
int bufferSize = MultiByteToWideChar(CP_UTF8, 0, myString, -1, nullptr, 0);
|
|
|
|
|
WCHAR* wideString = new WCHAR[bufferSize];
|
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, myString, -1, wideString, bufferSize);
|
|
|
|
|
return wideString;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpHardwareInfo::queryIsDesktop()
|
|
|
|
|
{
|
|
|
|
|
HRESULT hres;
|
|
|
|
|
DEVICE_PROPERTY dpRst;
|
|
|
|
|
|
|
|
|
|
CHAR* szSelect = "SELECT * FROM Win32_SystemEnclosure";
|
|
|
|
|
WCHAR* szProperty = L"ChassisTypes";
|
|
|
|
|
CHAR* szSelect = charReCHAR("SELECT * FROM Win32_SystemEnclosure");
|
|
|
|
|
WCHAR* szProperty = charReWCHAR("ChassisTypes");
|
|
|
|
|
|
|
|
|
|
IEnumWbemClassObject *pEnumerator = NULL;
|
|
|
|
|
hres = mpSvc->ExecQuery(bstr_t("WQL"), bstr_t(szSelect),
|
|
|
|
|
|