Initialize WMI only once, remove init calls from everywhere it is called and initialize it once as a static variable
* See comment: https://gitlab.com/CalcProgrammer1/OpenRGB/-/issues/1581#note_684260496
This commit is contained in:
parent
eaaed7fd83
commit
dd47256f06
6 changed files with 2 additions and 5 deletions
|
|
@ -16,7 +16,6 @@ static void DetectAsusTUFLaptopWMIControllers(std::vector<RGBController*>&)
|
||||||
// For now, checking for "TUF Gaming" should suffice
|
// For now, checking for "TUF Gaming" should suffice
|
||||||
|
|
||||||
Wmi wmi;
|
Wmi wmi;
|
||||||
wmi.init();
|
|
||||||
|
|
||||||
std::vector<QueryObj> systemProduct;
|
std::vector<QueryObj> systemProduct;
|
||||||
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
|
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
|
||||||
|
|
|
||||||
1
dependencies/dmiinfo.cpp
vendored
1
dependencies/dmiinfo.cpp
vendored
|
|
@ -27,7 +27,6 @@ DMIInfo::DMIInfo()
|
||||||
manufacturer = "";
|
manufacturer = "";
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
Wmi wmi;
|
Wmi wmi;
|
||||||
wmi.init();
|
|
||||||
|
|
||||||
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
||||||
// These devices may be browsed under Device Manager -> System Devices
|
// These devices may be browsed under Device Manager -> System Devices
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,6 @@ void i2c_smbus_i801_detect()
|
||||||
i2c_smbus_interface * bus;
|
i2c_smbus_interface * bus;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
Wmi wmi;
|
Wmi wmi;
|
||||||
wmi.init();
|
|
||||||
|
|
||||||
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
||||||
// These devices may be browsed under Device Manager -> System Devices
|
// These devices may be browsed under Device Manager -> System Devices
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,6 @@ void i2c_smbus_piix4_detect()
|
||||||
i2c_smbus_interface * bus;
|
i2c_smbus_interface * bus;
|
||||||
HRESULT hres;
|
HRESULT hres;
|
||||||
Wmi wmi;
|
Wmi wmi;
|
||||||
wmi.init();
|
|
||||||
|
|
||||||
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
||||||
// These devices may be browsed under Device Manager -> System Devices
|
// These devices may be browsed under Device Manager -> System Devices
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
IWbemLocator* Wmi::pLoc = nullptr;
|
IWbemLocator* Wmi::pLoc = nullptr;
|
||||||
IWbemServices* Wmi::pSvc = nullptr;
|
IWbemServices* Wmi::pSvc = nullptr;
|
||||||
|
HRESULT WmiInit = Wmi::init();
|
||||||
|
|
||||||
// Taken from https://stackoverflow.com/questions/215963/
|
// Taken from https://stackoverflow.com/questions/215963/
|
||||||
// Convert a wide Unicode string to an UTF8 string
|
// Convert a wide Unicode string to an UTF8 string
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ public:
|
||||||
~Wmi();
|
~Wmi();
|
||||||
|
|
||||||
// Initialises connection to WMI host
|
// Initialises connection to WMI host
|
||||||
HRESULT init();
|
static HRESULT init();
|
||||||
|
|
||||||
HRESULT query(std::string queryStr,
|
HRESULT query(std::string queryStr,
|
||||||
std::vector<QueryObj>& queryVectorOut,
|
std::vector<QueryObj>& queryVectorOut,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue