From ded52cbaac5508abfdce74ade83351d4efbaddd2 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Wed, 3 Dec 2014 20:13:16 +0000 Subject: StartupStatus: -code cleanup -minor bugfix git-svn-id: http://svn.miranda-ng.org/main/trunk@11230 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/StatusPlugins/StartupStatus/options.cpp | 28 +++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'plugins/StatusPlugins/StartupStatus/options.cpp') diff --git a/plugins/StatusPlugins/StartupStatus/options.cpp b/plugins/StatusPlugins/StartupStatus/options.cpp index 8661aa7d02..708ff717fb 100644 --- a/plugins/StatusPlugins/StartupStatus/options.cpp +++ b/plugins/StatusPlugins/StartupStatus/options.cpp @@ -133,7 +133,7 @@ static TCHAR* GetLinkDescription(TSettingsList& protoSettings) if ( protoSettings.getCount() == 0 ) return NULL; - CMString result( _T(SHORTCUT_DESC)); + CMString result(SHORTCUT_DESC); for (int i=0; i < protoSettings.getCount(); i++) { TSSSetting &p = protoSettings[i]; @@ -159,20 +159,19 @@ static TCHAR* GetLinkDescription(TSettingsList& protoSettings) HRESULT CreateLink(TSettingsList& protoSettings) { - HRESULT hres; - IShellLink* psl; TCHAR savePath[MAX_PATH]; - char *args = GetCMDLArguments(protoSettings); - TCHAR *desc = GetLinkDescription(protoSettings); - if (SHGetSpecialFolderPath(NULL, savePath, 0x10, FALSE)) - _tcscat(savePath, _T(SHORTCUT_FILENAME)); + _tcsncat(savePath, SHORTCUT_FILENAME, SIZEOF(savePath)); else - mir_sntprintf(savePath, SIZEOF(savePath), _T(".\\%s"), _T(SHORTCUT_FILENAME)); + mir_sntprintf(savePath, SIZEOF(savePath), _T(".\\%s"), SHORTCUT_FILENAME); // Get a pointer to the IShellLink interface. - hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, ( void** )&psl); + IShellLink *psl; + HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, ( void** )&psl); if (SUCCEEDED(hres)) { + char *args = GetCMDLArguments(protoSettings); + TCHAR *desc = GetLinkDescription(protoSettings); + // Set the path to the shortcut target, and add the // description. TCHAR path[MAX_PATH]; @@ -183,22 +182,19 @@ HRESULT CreateLink(TSettingsList& protoSettings) // Query IShellLink for the IPersistFile interface for saving the // shortcut in persistent storage. - IPersistFile* ppf; + IPersistFile *ppf; hres = psl->QueryInterface(IID_IPersistFile, ( void** )&ppf); if (SUCCEEDED(hres)) { - - WCHAR* wsz = savePath; - // Save the link by calling IPersistFile::Save. - hres = ppf->Save(wsz, TRUE); + hres = ppf->Save(savePath, TRUE); ppf->Release(); } psl->Release(); + free(args); + free(desc); } - free(args); - free(desc); return hres; } -- cgit v1.2.3