|
|
|
|
@ -26,27 +26,32 @@
|
|
|
|
|
\******************************************************************************************/
|
|
|
|
|
DMIInfo::DMIInfo()
|
|
|
|
|
{
|
|
|
|
|
mainboard = "";
|
|
|
|
|
manufacturer = "";
|
|
|
|
|
mainboard = readWMIQuery("SELECT * FROM Win32_BaseBoard", "Product");
|
|
|
|
|
manufacturer = readWMIQuery("SELECT * FROM Win32_BaseBoard", "Manufacturer");
|
|
|
|
|
product_name = readWMIQuery("SELECT * FROM Win32_ComputerSystem", "Model");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string DMIInfo::readWMIQuery(std::string query, std::string key)
|
|
|
|
|
{
|
|
|
|
|
HRESULT hres;
|
|
|
|
|
Wmi wmi;
|
|
|
|
|
|
|
|
|
|
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
|
|
|
|
// These devices may be browsed under Device Manager -> System Devices
|
|
|
|
|
std::vector<QueryObj> q_res_BaseBoard;
|
|
|
|
|
hres = wmi.query("SELECT * FROM Win32_BaseBoard", q_res_BaseBoard);
|
|
|
|
|
std::vector<QueryObj> q_result;
|
|
|
|
|
hres = wmi.query(query, q_result);
|
|
|
|
|
|
|
|
|
|
if (hres)
|
|
|
|
|
if(hres)
|
|
|
|
|
{
|
|
|
|
|
LOG_DEBUG("[DMI Info] Unable to read from %s", WMI);
|
|
|
|
|
return;
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (QueryObj &i : q_res_BaseBoard)
|
|
|
|
|
for(QueryObj &obj : q_result)
|
|
|
|
|
{
|
|
|
|
|
manufacturer = i["Manufacturer"].c_str();
|
|
|
|
|
mainboard = i["Product"].c_str();
|
|
|
|
|
return obj[key];
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
#else /* WIN32 */
|
|
|
|
|
|
|
|
|
|
@ -62,22 +67,24 @@ DMIInfo::DMIInfo()
|
|
|
|
|
\******************************************************************************************/
|
|
|
|
|
DMIInfo::DMIInfo()
|
|
|
|
|
{
|
|
|
|
|
mainboard = "";
|
|
|
|
|
manufacturer = "";
|
|
|
|
|
mainboard = readFilePath(SYSFS_MB_DMI "/board_vendor");
|
|
|
|
|
manufacturer = readFilePath(SYSFS_MB_DMI "/board_name");
|
|
|
|
|
product_name = readFilePath(SYSFS_PC_DMI "/product_name");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((access(SYSFSDMI "/board_vendor", R_OK)!=0) && (access(SYSFSDMI "/board_name", R_OK)!=0))
|
|
|
|
|
std::string DMIInfo::readFilePath(std::string path)
|
|
|
|
|
{
|
|
|
|
|
if(access(path.c_str(), R_OK)!=0)
|
|
|
|
|
{
|
|
|
|
|
LOG_DEBUG("[DMI Info] Unable to read from %s", SYSFSDMI);
|
|
|
|
|
return;
|
|
|
|
|
LOG_DEBUG("[DMI Info] Unable to read from %s", path);
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
std::string read_path;
|
|
|
|
|
|
|
|
|
|
std::ifstream mftr(SYSFSDMI "/board_vendor", std::ifstream::in);
|
|
|
|
|
getline(mftr, manufacturer);
|
|
|
|
|
mftr.close();
|
|
|
|
|
|
|
|
|
|
std::ifstream prdt(SYSFSDMI "/board_name", std::ifstream::in);
|
|
|
|
|
getline(prdt, mainboard);
|
|
|
|
|
prdt.close();
|
|
|
|
|
std::ifstream path_stream(path, std::ifstream::in);
|
|
|
|
|
getline(path_stream, read_path);
|
|
|
|
|
path_stream.close();
|
|
|
|
|
return read_path;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
|
|
|
|
|
@ -95,3 +102,8 @@ std::string DMIInfo::getManufacturer()
|
|
|
|
|
{
|
|
|
|
|
return manufacturer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string DMIInfo::getProductName()
|
|
|
|
|
{
|
|
|
|
|
return product_name;
|
|
|
|
|
}
|
|
|
|
|
|