MCPcopy Create free account
hub / github.com/Icinga/icinga2 / printPDHError

Function printPDHError

plugins/check_perfmon.cpp:178–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176}
177
178static void printPDHError(PDH_STATUS status)
179{
180 HMODULE hPdhLibrary = NULL;
181 LPWSTR pMessage = NULL;
182
183 hPdhLibrary = LoadLibrary(L"pdh.dll");
184 if (!hPdhLibrary) {
185 std::wcout << "LoadLibrary failed with " << GetLastError() << '\n';
186 return;
187 }
188
189 if (!FormatMessage(FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ARGUMENT_ARRAY,
190 hPdhLibrary, status, 0, (LPWSTR)&pMessage, 0, NULL)) {
191 FreeLibrary(hPdhLibrary);
192 std::wcout << "Format message failed with " << std::hex << GetLastError() << '\n';
193 return;
194 }
195
196 FreeLibrary(hPdhLibrary);
197
198 std::wcout << pMessage << '\n';
199 LocalFree(pMessage);
200}
201
202static void printObjects()
203{

Callers 2

printObjectsFunction · 0.85
QueryPerfDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected