Refactor to use Microsoft::WRL::ComPtr (#1599)
Some checks failed
Generate translation template / generate-pot (push) Failing after 2m59s
Build check / build (push) Has been cancelled

This commit is contained in:
oltolm 2025-06-16 23:25:06 +02:00 committed by GitHub
parent da98aa4176
commit 2f02fda9ea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 56 additions and 119 deletions

View file

@ -45,6 +45,7 @@
#include <objidl.h>
#include <shlguid.h>
#include <shlobj.h>
#include <wrl/client.h>
#endif
// public events
@ -1630,8 +1631,8 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
}
}
IShellLinkW* shellLink;
HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast<LPVOID*>(&shellLink));
Microsoft::WRL::ComPtr<IShellLinkW> shellLink;
HRESULT hres = CoCreateInstance(__uuidof(ShellLink), nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
if (SUCCEEDED(hres))
{
const auto description = wxString::Format("Play %s on Cemu", titleName);
@ -1647,15 +1648,13 @@ void wxGameList::CreateShortcut(GameInfo2& gameInfo)
else
shellLink->SetIconLocation(exePath.wstring().c_str(), 0);
IPersistFile* shellLinkFile;
Microsoft::WRL::ComPtr<IPersistFile> shellLinkFile;
// save the shortcut
hres = shellLink->QueryInterface(IID_IPersistFile, reinterpret_cast<LPVOID*>(&shellLinkFile));
hres = shellLink.As(&shellLinkFile);
if (SUCCEEDED(hres))
{
hres = shellLinkFile->Save(outputPath.wc_str(), TRUE);
shellLinkFile->Release();
}
shellLink->Release();
}
if (!SUCCEEDED(hres)) {
auto errorMsg = formatWxString(_("Failed to save shortcut to {}"), outputPath);