From ba6758788a83706e0b240fff7d93050656c8449e Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 29 Aug 2015 12:59:53 +0000 Subject: Toaster: code cleanup; version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@15090 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Toaster/src/add_to_start_menu.cpp | 35 ++++++------------------------- plugins/Toaster/src/stdafx.h | 11 +++++++++- plugins/Toaster/src/version.h | 4 ++-- 3 files changed, 18 insertions(+), 32 deletions(-) (limited to 'plugins/Toaster/src') diff --git a/plugins/Toaster/src/add_to_start_menu.cpp b/plugins/Toaster/src/add_to_start_menu.cpp index ae2d1e7131..ac0f2ff7b2 100644 --- a/plugins/Toaster/src/add_to_start_menu.cpp +++ b/plugins/Toaster/src/add_to_start_menu.cpp @@ -1,38 +1,15 @@ #include "stdafx.h" +#define SHORTCUT_PATH "\\Microsoft\\Windows\\Start Menu\\Programs\\Miranda NG.lnk" + using namespace Microsoft::WRL; wchar_t* GetShortcutPath() { - wchar_t shortcutPath[MAX_PATH]; - GetEnvironmentVariable(_T("APPDATA"), shortcutPath, MAX_PATH); - wcscat_s(shortcutPath, ARRAYSIZE(shortcutPath), L"\\Microsoft\\Windows\\Start Menu\\Programs\\Miranda NG.lnk"); - - return mir_wstrdup(shortcutPath); -} - -HRESULT ShortcutExists() -{ - HRESULT hr; - DWORD attributes = GetFileAttributes(ptrW(GetShortcutPath())); - bool fileExists = attributes < 0xFFFFFFF; - - if (!fileExists) - { - hr = S_OK; - } - else - { - hr = S_FALSE; - } - return hr; -} - -HRESULT TryCreateShortcut() -{ - if (!ShortcutExists()) - return InstallShortcut(ptrW(GetShortcutPath())); - return S_OK; + wchar_t path[MAX_PATH]; + GetEnvironmentVariable(_T("APPDATA"), path, MAX_PATH); + wcscat_s(path, _T(SHORTCUT_PATH)); + return mir_wstrdup(path); } HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath) diff --git a/plugins/Toaster/src/stdafx.h b/plugins/Toaster/src/stdafx.h index 2e2e59cd1c..f5c193c328 100644 --- a/plugins/Toaster/src/stdafx.h +++ b/plugins/Toaster/src/stdafx.h @@ -50,8 +50,17 @@ int OnPreShutdown(WPARAM, LPARAM); INT_PTR Service(WPARAM, LPARAM); HRESULT ShortcutExists(); wchar_t* GetShortcutPath(); -HRESULT TryCreateShortcut(); HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath); +__forceinline HRESULT TryCreateShortcut() +{ + return (ShortcutExists() ? S_OK : InstallShortcut(ptrW(GetShortcutPath()))); +} + +__forceinline HRESULT ShortcutExists() +{ + return (!(GetFileAttributes(ptrW(GetShortcutPath())) < 0xFFFFFFF) ? S_OK : S_FALSE); +} + #endif //_COMMON_H_ diff --git a/plugins/Toaster/src/version.h b/plugins/Toaster/src/version.h index aea2503105..7a0f1cdd24 100644 --- a/plugins/Toaster/src/version.h +++ b/plugins/Toaster/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 11 -#define __RELEASE_NUM 0 -#define __BUILD_NUM 2 +#define __RELEASE_NUM 1 +#define __BUILD_NUM 0 #include -- cgit v1.2.3