MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / init

Method init

wmi/wmi.cpp:49–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49HRESULT Wmi::init()
50{
51 HRESULT hres;
52
53 if(pLoc != nullptr && pSvc != nullptr)
54 {
55 return S_OK;
56 }
57
58 // Initialize COM. ------------------------------------------
59 hres = CoInitializeEx(0, COINIT_APARTMENTTHREADED);
60 if (FAILED(hres))
61 {
62 return hres;
63 }
64
65 // Set general COM security levels --------------------------
66 hres = CoInitializeSecurity(
67 nullptr,
68 -1, // COM authentication
69 nullptr, // Authentication services
70 nullptr, // Reserved
71 RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
72 RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
73 nullptr, // Authentication info
74 EOAC_NONE, // Additional capabilities
75 nullptr // Reserved
76 );
77
78 if (FAILED(hres))
79 {
80 CoUninitialize();
81 return hres;
82 }
83
84 // Obtain the initial locator to WMI -------------------------
85 hres = CoCreateInstance(
86 CLSID_WbemLocator,
87 nullptr,
88 CLSCTX_INPROC_SERVER,
89 IID_IWbemLocator, (LPVOID*) &pLoc
90 );
91
92 if (FAILED(hres))
93 {
94 CoUninitialize();
95 return hres;
96 }
97
98 hres = pLoc->ConnectServer(
99 _bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
100 nullptr, // User name. NULL = current user
101 nullptr, // User password. NULL = current
102 nullptr, // Locale. NULL indicates current
103 0, // Security flags.
104 nullptr, // Authority (for example, Kerberos)
105 nullptr, // Context object
106 &pSvc // pointer to IWbemServices proxy

Callers 9

getWirelessDeviceFunction · 0.80
connectedMethod · 0.80
flushReadQueueMethod · 0.80
getFeatureIndexMethod · 0.80
getDeviceFeatureListMethod · 0.80
getDeviceNameMethod · 0.80
getRGBconfigMethod · 0.80
setDirectModeMethod · 0.80
setModeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected