diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-28 17:31:03 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-08-28 17:31:03 +0000 |
commit | 40115052f14e4285bbc5bfa2de69a7bd51f5d13b (patch) | |
tree | 706b1d37b34bbb385cb19fcf187c847b120cfc4a /plugins/AddToStartMenu/src/main.cpp | |
parent | 9d81a96b2de32c863829cc048a516b943180fc79 (diff) |
AddToStartMenu: includes cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@15067 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AddToStartMenu/src/main.cpp')
-rw-r--r-- | plugins/AddToStartMenu/src/main.cpp | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/plugins/AddToStartMenu/src/main.cpp b/plugins/AddToStartMenu/src/main.cpp index 5c4da0766c..6b3a86ebaa 100644 --- a/plugins/AddToStartMenu/src/main.cpp +++ b/plugins/AddToStartMenu/src/main.cpp @@ -99,49 +99,41 @@ HRESULT TryCreateShortcut() HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath)
{
wchar_t exePath[MAX_PATH];
+ GetModuleFileName(NULL, exePath, MAX_PATH);
- DWORD charWritten = GetModuleFileNameEx(GetCurrentProcess(), nullptr, exePath, ARRAYSIZE(exePath));
-
- HRESULT hr = charWritten > 0 ? S_OK : E_FAIL;
-
+ ComPtr<IShellLink> shellLink;
+ HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
if (SUCCEEDED(hr))
{
- ComPtr<IShellLink> shellLink;
- hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
-
+ hr = shellLink->SetPath(exePath);
if (SUCCEEDED(hr))
{
- hr = shellLink->SetPath(exePath);
+ hr = shellLink->SetArguments(L"");
if (SUCCEEDED(hr))
{
- hr = shellLink->SetArguments(L"");
+ ComPtr<IPropertyStore> propertyStore;
+ hr = shellLink.As(&propertyStore);
if (SUCCEEDED(hr))
{
- ComPtr<IPropertyStore> propertyStore;
-
- hr = shellLink.As(&propertyStore);
+ PROPVARIANT appIdPropVar;
+ hr = InitPropVariantFromString(AppUserModelID, &appIdPropVar);
if (SUCCEEDED(hr))
{
- PROPVARIANT appIdPropVar;
- hr = InitPropVariantFromString(AppUserModelID, &appIdPropVar);
+ hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
if (SUCCEEDED(hr))
{
- hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
+ hr = propertyStore->Commit();
if (SUCCEEDED(hr))
{
- hr = propertyStore->Commit();
+ ComPtr<IPersistFile> persistFile;
+ hr = shellLink.As(&persistFile);
if (SUCCEEDED(hr))
{
- ComPtr<IPersistFile> persistFile;
- hr = shellLink.As(&persistFile);
- if (SUCCEEDED(hr))
- {
- hr = persistFile->Save(shortcutPath, TRUE);
- }
+ hr = persistFile->Save(shortcutPath, TRUE);
}
}
- PropVariantClear(&appIdPropVar);
}
+ PropVariantClear(&appIdPropVar);
}
}
}
|