mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 17:49:29 +01:00
use ComPtr for misc. things
This commit is contained in:
1 parent
60c98a6483
commit
5c1412f84d
12 files changed
+110
-126
No files matched your search
+15
-11
@@ -16,6 +16,9 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "stdafx.h"
|
||||
#ifdef _WIN32
|
||||
#include <initguid.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
@@ -30,6 +33,7 @@
|
||||
#include <shellapi.h>
|
||||
#include <Wbemidl.h>
|
||||
#include <ShlObj.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
@@ -84,6 +88,11 @@
|
||||
#include "Windows/WindowsHost.h"
|
||||
#include "Windows/main.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "wbemuuid")
|
||||
#endif
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
// Nvidia OpenGL drivers >= v302 will check if the application exports a global
|
||||
// variable named NvOptimusEnablement to know if it should run the app in high
|
||||
@@ -147,35 +156,33 @@ std::string GetVideoCardDriverVersion() {
|
||||
return retvalue;
|
||||
}
|
||||
|
||||
IWbemLocator *pIWbemLocator = NULL;
|
||||
hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER,
|
||||
__uuidof(IWbemLocator), (LPVOID *)&pIWbemLocator);
|
||||
ComPtr<IWbemLocator> pIWbemLocator;
|
||||
hr = CoCreateInstance(__uuidof(WbemLocator), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pIWbemLocator));
|
||||
if (FAILED(hr)) {
|
||||
CoUninitialize();
|
||||
return retvalue;
|
||||
}
|
||||
|
||||
BSTR bstrServer = SysAllocString(L"\\\\.\\root\\cimv2");
|
||||
IWbemServices *pIWbemServices;
|
||||
ComPtr<IWbemServices> pIWbemServices;
|
||||
hr = pIWbemLocator->ConnectServer(bstrServer, NULL, NULL, 0L, 0L, NULL, NULL, &pIWbemServices);
|
||||
if (FAILED(hr)) {
|
||||
pIWbemLocator->Release();
|
||||
SysFreeString(bstrServer);
|
||||
CoUninitialize();
|
||||
return retvalue;
|
||||
}
|
||||
|
||||
hr = CoSetProxyBlanket(pIWbemServices, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,
|
||||
hr = CoSetProxyBlanket(pIWbemServices.Get(), RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,
|
||||
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL,EOAC_DEFAULT);
|
||||
|
||||
BSTR bstrWQL = SysAllocString(L"WQL");
|
||||
BSTR bstrPath = SysAllocString(L"select * from Win32_VideoController");
|
||||
IEnumWbemClassObject* pEnum;
|
||||
ComPtr<IEnumWbemClassObject> pEnum;
|
||||
hr = pIWbemServices->ExecQuery(bstrWQL, bstrPath, WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum);
|
||||
|
||||
ULONG uReturned = 0;
|
||||
VARIANT var{};
|
||||
IWbemClassObject* pObj = NULL;
|
||||
ComPtr<IWbemClassObject> pObj;
|
||||
if (!FAILED(hr)) {
|
||||
hr = pEnum->Next(WBEM_INFINITE, 1, &pObj, &uReturned);
|
||||
}
|
||||
@@ -189,11 +196,8 @@ std::string GetVideoCardDriverVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
pEnum->Release();
|
||||
SysFreeString(bstrPath);
|
||||
SysFreeString(bstrWQL);
|
||||
pIWbemServices->Release();
|
||||
pIWbemLocator->Release();
|
||||
SysFreeString(bstrServer);
|
||||
CoUninitialize();
|
||||
return retvalue;
|
||||
|
||||
Reference in new issue
Block a user