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 | |
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')
-rw-r--r-- | plugins/AddToStartMenu/src/main.cpp | 38 | ||||
-rw-r--r-- | plugins/AddToStartMenu/src/stdafx.h | 7 |
2 files changed, 17 insertions, 28 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);
}
}
}
diff --git a/plugins/AddToStartMenu/src/stdafx.h b/plugins/AddToStartMenu/src/stdafx.h index 587fba5c3a..439407cffe 100644 --- a/plugins/AddToStartMenu/src/stdafx.h +++ b/plugins/AddToStartMenu/src/stdafx.h @@ -1,12 +1,7 @@ #pragma once
-#include <Windows.h>
-#include <Psapi.h>
-
#include <ShObjIdl.h>
#include <propvarutil.h>
-#include <functiondiscoverykeys.h>
-#include <wrl\client.h>
#include <wrl\implements.h>
#include <newpluginapi.h>
#include <m_langpack.h>
@@ -15,6 +10,8 @@ #include <m_clist.h>
#include "Version.h"
+DEFINE_PROPERTYKEY(PKEY_AppUserModel_ID, 0x9F4C2855, 0x9F79, 0x4B39, 0xA8, 0xD0, 0xE1, 0xD4, 0x2D, 0xE1, 0xD5, 0xF3, 5);
+
const wchar_t AppUserModelID[] = _T("MirandaNG");
#define MODULENAME "AddToStartMenu"
|