Add shortcut to programs on install
This commit is contained in:
parent
d155b0ffc1
commit
a17a2fe6c7
@ -17,6 +17,7 @@
|
|||||||
#ifdef WIN
|
#ifdef WIN
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
|
#include <objidl.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
@ -159,6 +160,11 @@ bool Client::IsFirstRun()
|
|||||||
bool Client::DoInstallation()
|
bool Client::DoInstallation()
|
||||||
{
|
{
|
||||||
#if defined(WIN)
|
#if defined(WIN)
|
||||||
|
CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||||
|
wchar_t programsPath[MAX_PATH];
|
||||||
|
IShellLinkW *shellLink = NULL;
|
||||||
|
IPersistFile *shellLinkPersist = NULL;
|
||||||
|
|
||||||
int returnval;
|
int returnval;
|
||||||
LONG rresult;
|
LONG rresult;
|
||||||
HKEY newkey;
|
HKEY newkey;
|
||||||
@ -293,9 +299,25 @@ bool Client::DoInstallation()
|
|||||||
}
|
}
|
||||||
RegCloseKey(newkey);
|
RegCloseKey(newkey);
|
||||||
|
|
||||||
|
if (SHGetFolderPathW(NULL, CSIDL_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, programsPath) != S_OK)
|
||||||
|
goto finalise;
|
||||||
|
if (CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&shellLink) != S_OK)
|
||||||
|
goto finalise;
|
||||||
|
shellLink->SetPath(Platform::WinWiden(currentfilename).c_str());
|
||||||
|
shellLink->SetDescription(L"The Powder Toy");
|
||||||
|
if (shellLink->QueryInterface(IID_IPersistFile, (LPVOID *)&shellLinkPersist) != S_OK)
|
||||||
|
goto finalise;
|
||||||
|
shellLinkPersist->Save(Platform::WinWiden(Platform::WinNarrow(programsPath) + "\\The Powder Toy.lnk").c_str(), TRUE);
|
||||||
|
|
||||||
returnval = 1;
|
returnval = 1;
|
||||||
finalise:
|
finalise:
|
||||||
|
|
||||||
|
if (shellLinkPersist)
|
||||||
|
shellLinkPersist->Release();
|
||||||
|
if (shellLink)
|
||||||
|
shellLink->Release();
|
||||||
|
CoUninitialize();
|
||||||
|
|
||||||
return returnval;
|
return returnval;
|
||||||
#elif defined(LIN)
|
#elif defined(LIN)
|
||||||
#include "icondoc.h"
|
#include "icondoc.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user