ACPPage.cpp (e419195d) ACPPage.cpp (d82185f1)
1/*
2 * PROJECT: ReactOS Compatibility Layer Shell Extension
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: acppage entrypoint
5 * COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include "precomp.h"

--- 61 unchanged lines hidden (view full) ---

70
71 hr = gModule.DllUnregisterServer(FALSE);
72 if (FAILED(hr))
73 return hr;
74
75 return S_OK;
76}
77
1/*
2 * PROJECT: ReactOS Compatibility Layer Shell Extension
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: acppage entrypoint
5 * COPYRIGHT: Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include "precomp.h"

--- 61 unchanged lines hidden (view full) ---

70
71 hr = gModule.DllUnregisterServer(FALSE);
72 if (FAILED(hr))
73 return hr;
74
75 return S_OK;
76}
77
78struct CCoInit
79{
80 CCoInit() { hres = CoInitialize(NULL); }
81 ~CCoInit() { if (SUCCEEDED(hres)) { CoUninitialize(); } }
82 HRESULT hres;
83};
84
85EXTERN_C
86BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
87{
88 CCoInit init;
78EXTERN_C
79BOOL WINAPI GetExeFromLnk(PCWSTR pszLnk, PWSTR pszExe, size_t cchSize)
80{
81 CCoInit init;
89 if (FAILED_UNEXPECTEDLY(init.hres))
82 if (FAILED_UNEXPECTEDLY(init.hr))
90 return FALSE;
91
92 CComPtr<IShellLinkW> spShellLink;
93 if (FAILED_UNEXPECTEDLY(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
94 return FALSE;
95
96 CComPtr<IPersistFile> spPersistFile;
97 if (FAILED_UNEXPECTEDLY(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
98 return FALSE;
99
100 if (FAILED_UNEXPECTEDLY(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED_UNEXPECTEDLY(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
101 return FALSE;
102
103 return !FAILED_UNEXPECTEDLY(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
104}
83 return FALSE;
84
85 CComPtr<IShellLinkW> spShellLink;
86 if (FAILED_UNEXPECTEDLY(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellLinkW, &spShellLink))))
87 return FALSE;
88
89 CComPtr<IPersistFile> spPersistFile;
90 if (FAILED_UNEXPECTEDLY(spShellLink->QueryInterface(IID_PPV_ARG(IPersistFile, &spPersistFile))))
91 return FALSE;
92
93 if (FAILED_UNEXPECTEDLY(spPersistFile->Load(pszLnk, STGM_READ)) || FAILED_UNEXPECTEDLY(spShellLink->Resolve(NULL, SLR_NO_UI | SLR_NOUPDATE | SLR_NOSEARCH)))
94 return FALSE;
95
96 return !FAILED_UNEXPECTEDLY(spShellLink->GetPath(pszExe, cchSize, NULL, SLGP_RAWPATH));
97}