mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-02 15:32:52 +00:00
use ComPtr in gui_context_menus.h
This commit is contained in:
parent
45e206e248
commit
4cb48a358b
@ -20,6 +20,7 @@
|
|||||||
#include <objbase.h>
|
#include <objbase.h>
|
||||||
#include <shlguid.h>
|
#include <shlguid.h>
|
||||||
#include <shobjidl.h>
|
#include <shobjidl.h>
|
||||||
|
#include <wrl/client.h>
|
||||||
#endif
|
#endif
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
|
|
||||||
@ -342,9 +343,9 @@ private:
|
|||||||
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||||
|
|
||||||
// Create the ShellLink object
|
// Create the ShellLink object
|
||||||
IShellLink* pShellLink = nullptr;
|
Microsoft::WRL::ComPtr<IShellLink> pShellLink;
|
||||||
HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
|
HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
|
||||||
IID_IShellLink, (LPVOID*)&pShellLink);
|
IID_PPV_ARGS(&pShellLink));
|
||||||
if (SUCCEEDED(hres)) {
|
if (SUCCEEDED(hres)) {
|
||||||
// Defines the path to the program executable
|
// Defines the path to the program executable
|
||||||
pShellLink->SetPath((LPCWSTR)exePath.utf16());
|
pShellLink->SetPath((LPCWSTR)exePath.utf16());
|
||||||
@ -360,13 +361,11 @@ private:
|
|||||||
pShellLink->SetIconLocation((LPCWSTR)iconPath.utf16(), 0);
|
pShellLink->SetIconLocation((LPCWSTR)iconPath.utf16(), 0);
|
||||||
|
|
||||||
// Save the shortcut
|
// Save the shortcut
|
||||||
IPersistFile* pPersistFile = nullptr;
|
Microsoft::WRL::ComPtr<IPersistFile> pPersistFile;
|
||||||
hres = pShellLink->QueryInterface(IID_IPersistFile, (LPVOID*)&pPersistFile);
|
hres = pShellLink.As(&pPersistFile);
|
||||||
if (SUCCEEDED(hres)) {
|
if (SUCCEEDED(hres)) {
|
||||||
hres = pPersistFile->Save((LPCWSTR)linkPath.utf16(), TRUE);
|
hres = pPersistFile->Save((LPCWSTR)linkPath.utf16(), TRUE);
|
||||||
pPersistFile->Release();
|
|
||||||
}
|
}
|
||||||
pShellLink->Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CoUninitialize();
|
CoUninitialize();
|
||||||
|
Loading…
Reference in New Issue
Block a user