* @brief Implementation file for JumpList helper functions.
*
*/
+#include "pch.h"
#include "JumpList.h"
#include <vector>
-#include <ObjBase.h>
-#include <ShlObj.h>
+#pragma warning (push) // prevent "warning C4091: 'typedef ': ignored on left of 'tagGPFIDL_FLAGS' when no variable is declared"
+#pragma warning (disable:4091) // VC bug when using XP enabled toolsets.
+#include <shlobj.h>
+#pragma warning (pop)
#include <propvarutil.h>
#include <propkey.h>
#include "unicoder.h"
IShellLinkW *CreateShellLink(const std::wstring& app_path, const std::wstring& params, const std::wstring& title, const std::wstring& desc, int icon_index)
{
- IShellLinkW *pShellLink = NULL;
- if (FAILED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IShellLinkW *pShellLink = nullptr;
+ if (FAILED(CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER,
IID_IShellLinkW, (void **)&pShellLink)))
- return NULL;
+ return nullptr;
std::wstring app_path2(app_path);
if (app_path.empty())
{
if (g_exe_path[0] == '\0')
- GetModuleFileNameW(NULL, g_exe_path, sizeof(g_exe_path)/sizeof(g_exe_path[0]));
+ GetModuleFileNameW(nullptr, g_exe_path, sizeof(g_exe_path)/sizeof(g_exe_path[0]));
app_path2 = g_exe_path;
}
pShellLink->SetPath(app_path2.c_str());
pShellLink->SetArguments(params.c_str());
pShellLink->SetDescription(desc.c_str());
- IPropertyStore *pPS = NULL;
+ IPropertyStore *pPS = nullptr;
if (SUCCEEDED(pShellLink->QueryInterface(IID_IPropertyStore, (void **)&pPS)))
{
PROPVARIANT pv;
{
g_appid = appid;
HMODULE hLibrary = GetModuleHandle(_T("shell32.dll"));
- if (!hLibrary)
+ if (hLibrary == nullptr)
return false;
HRESULT (__stdcall *pfnSetCurrentProcessExplicitAppUserModelID)(PCWSTR AppID) =
(HRESULT (__stdcall *)(PCWSTR))GetProcAddress(hLibrary, "SetCurrentProcessExplicitAppUserModelID");
- if (!pfnSetCurrentProcessExplicitAppUserModelID)
+ if (pfnSetCurrentProcessExplicitAppUserModelID == nullptr)
return false;
return pfnSetCurrentProcessExplicitAppUserModelID(appid.c_str()) == S_OK;
}
{
SHARDAPPIDINFOLINK saiil;
saiil.pszAppID = g_appid.c_str();
-#ifdef _UNICODE
saiil.psl = CreateShellLink(app_path, params, title, desc, icon_index);
-#else
- saiil.psl = (IShellLink *)CreateShellLink(ucr::toUTF16(app_path), ucr::toUTF16(params), ucr::toUTF16(title), ucr::toUTF16(desc), icon_index);
-#endif
- if (!saiil.psl)
+ if (saiil.psl == nullptr)
return false;
SHAddToRecentDocs(SHARD_APPIDINFOLINK, &saiil);
saiil.psl->Release();
std::vector<Item> GetRecentDocs(size_t nMaxItems)
{
std::vector<Item> list;
- IApplicationDocumentLists *pDocumentLists = NULL;
- if (FAILED(CoCreateInstance(CLSID_ApplicationDocumentLists, NULL, CLSCTX_INPROC_SERVER,
+ IApplicationDocumentLists *pDocumentLists = nullptr;
+ if (FAILED(CoCreateInstance(CLSID_ApplicationDocumentLists, nullptr, CLSCTX_INPROC_SERVER,
IID_IApplicationDocumentLists, (void **)&pDocumentLists)))
return list;
pDocumentLists->SetAppID(g_appid.c_str());
wchar_t szPath[MAX_PATH];
wchar_t szDescription[MAX_PATH];
wchar_t szArguments[MAX_PATH * 6];
- pShellLink->GetPath(szPath, sizeof(szPath) / sizeof(szPath[0]), NULL, SLGP_RAWPATH);
+ pShellLink->GetPath(szPath, sizeof(szPath) / sizeof(szPath[0]), nullptr, SLGP_RAWPATH);
pShellLink->GetDescription(szDescription, sizeof(szDescription) / sizeof(szDescription[0]));
pShellLink->GetArguments(szArguments, sizeof(szArguments) / sizeof(szArguments[0]));
- IPropertyStore *pPS = NULL;
+ IPropertyStore *pPS = nullptr;
if (SUCCEEDED(pShellLink->QueryInterface(IID_IPropertyStore, (void **)&pPS)))
{
PROPVARIANT pv;
+ PropVariantInit(&pv);
if (SUCCEEDED(pPS->GetValue(PKEY_Title, &pv)))
{
list.push_back(Item(ucr::toTString(szPath), ucr::toTString(szArguments), ucr::toTString(pv.bstrVal), ucr::toTString(szDescription)));