summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-28 12:07:44 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-28 12:07:44 +0000
commitd87f9ff6f923ae344ffe00465e97e71a001de2df (patch)
treee94830ff9b24cb0ff278749f5bc8fa88b5fc69f1 /plugins
parent4402f6924f14847c1570b22ef06ba54125a9c41c (diff)
AddToStartMenu: initial commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@15054 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/AddToStartMenu/AddToStartMenu.filters4
-rw-r--r--plugins/AddToStartMenu/AddToStartMenu.vcxproj52
-rw-r--r--plugins/AddToStartMenu/res/version.rc38
-rw-r--r--plugins/AddToStartMenu/src/main.cpp141
-rw-r--r--plugins/AddToStartMenu/src/stdafx.cxx18
-rw-r--r--plugins/AddToStartMenu/src/stdafx.h40
-rw-r--r--plugins/AddToStartMenu/src/version.h14
7 files changed, 307 insertions, 0 deletions
diff --git a/plugins/AddToStartMenu/AddToStartMenu.filters b/plugins/AddToStartMenu/AddToStartMenu.filters
new file mode 100644
index 0000000000..de5ad9f66c
--- /dev/null
+++ b/plugins/AddToStartMenu/AddToStartMenu.filters
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
+</Project> \ No newline at end of file
diff --git a/plugins/AddToStartMenu/AddToStartMenu.vcxproj b/plugins/AddToStartMenu/AddToStartMenu.vcxproj
new file mode 100644
index 0000000000..4aa21c45de
--- /dev/null
+++ b/plugins/AddToStartMenu/AddToStartMenu.vcxproj
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectName>AddToStartMenu</ProjectName>
+ <ProjectGuid>{2954e74f-57f3-421a-980c-681b54810c9a}</ProjectGuid>
+ </PropertyGroup>
+ <ImportGroup Label="PropertySheets">
+ <Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
+ </ImportGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSdk_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSdk_LibraryPath_x86);</LibraryPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSdk_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSdk_LibraryPath_x64);</LibraryPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSdk_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSdk_LibraryPath_x64);</LibraryPath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IncludePath>$(VC_IncludePath);$(WindowsSdk_IncludePath);</IncludePath>
+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSdk_LibraryPath_x86);</LibraryPath>
+ </PropertyGroup>
+ <ItemDefinitionGroup>
+ <Link>
+ <AdditionalDependencies>runtimeobject.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ <ClCompile>
+ <RuntimeLibrary Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebugDLL</RuntimeLibrary>
+ </ClCompile>
+ </ItemDefinitionGroup>
+</Project> \ No newline at end of file
diff --git a/plugins/AddToStartMenu/res/version.rc b/plugins/AddToStartMenu/res/version.rc
new file mode 100644
index 0000000000..5bfbab4754
--- /dev/null
+++ b/plugins/AddToStartMenu/res/version.rc
@@ -0,0 +1,38 @@
+// Microsoft Visual C++ generated resource script.
+//
+#ifdef APSTUDIO_INVOKED
+#error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+#include "afxres.h"
+#include "..\src\version.h"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x0L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 1200
+ END
+END
diff --git a/plugins/AddToStartMenu/src/main.cpp b/plugins/AddToStartMenu/src/main.cpp
new file mode 100644
index 0000000000..66f2b8e30e
--- /dev/null
+++ b/plugins/AddToStartMenu/src/main.cpp
@@ -0,0 +1,141 @@
+#include "stdafx.h"
+
+using namespace Microsoft::WRL;
+
+int hLangpack;
+HINSTANCE g_hInst;
+
+PLUGININFOEX pluginInfo =
+{
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {61D5BB60-2249-4E3D-B23E-8FB86F04ED40}
+ { 0x61d5bb60, 0x2249, 0x4e3d, { 0xb2, 0x3e, 0x8f, 0xb8, 0x6f, 0x4, 0xed, 0x40 } }
+
+};
+
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
+{
+ g_hInst = hInstance;
+ return TRUE;
+}
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
+{
+ return &pluginInfo;
+}
+
+extern "C" int __declspec(dllexport) Load(void)
+{
+ mir_getLP(&pluginInfo);
+
+ CreateServiceFunction(MODULENAME "/Add", Service);
+
+ CMenuItem mi;
+ mi.position = -0x7FFFFFFF;
+ //mi.hIcolibItem = icon.hIcolib;
+ mi.name.a = LPGEN("Add to start menu");
+ mi.pszService = MODULENAME "/Add";
+ Menu_AddMainMenuItem(&mi);
+
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload(void)
+{
+ return 0;
+}
+
+INT_PTR Service(WPARAM, LPARAM)
+{
+ return (INT_PTR)TryCreateShortcut();
+}
+
+HRESULT TryCreateShortcut()
+{
+ wchar_t shortcutPath[MAX_PATH];
+ DWORD charWritten = GetEnvironmentVariable(L"APPDATA", shortcutPath, MAX_PATH);
+ HRESULT hr = charWritten > 0 ? S_OK : E_INVALIDARG;
+
+ if (SUCCEEDED(hr))
+ {
+ errno_t concatError = wcscat_s(shortcutPath, ARRAYSIZE(shortcutPath), L"\\Microsoft\\Windows\\Start Menu\\Programs\\Miranda NG.lnk");
+ hr = concatError == 0 ? S_OK : E_INVALIDARG;
+ if (SUCCEEDED(hr))
+ {
+ DWORD attributes = GetFileAttributes(shortcutPath);
+ bool fileExists = attributes < 0xFFFFFFF;
+
+ if (!fileExists)
+ {
+ hr = InstallShortcut(shortcutPath);
+ }
+ else
+ {
+ hr = S_FALSE;
+ }
+ }
+ }
+ return hr;
+}
+
+HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath)
+{
+ wchar_t exePath[MAX_PATH];
+
+ DWORD charWritten = GetModuleFileNameEx(GetCurrentProcess(), nullptr, exePath, ARRAYSIZE(exePath));
+
+ HRESULT hr = charWritten > 0 ? S_OK : E_FAIL;
+
+ if (SUCCEEDED(hr))
+ {
+ ComPtr<IShellLink> shellLink;
+ hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
+
+ if (SUCCEEDED(hr))
+ {
+ hr = shellLink->SetPath(exePath);
+ if (SUCCEEDED(hr))
+ {
+ hr = shellLink->SetArguments(L"");
+ if (SUCCEEDED(hr))
+ {
+ ComPtr<IPropertyStore> propertyStore;
+
+ hr = shellLink.As(&propertyStore);
+ if (SUCCEEDED(hr))
+ {
+ PROPVARIANT appIdPropVar;
+ hr = InitPropVariantFromString(AppUserModelID, &appIdPropVar);
+ if (SUCCEEDED(hr))
+ {
+ hr = propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);
+ if (SUCCEEDED(hr))
+ {
+ hr = propertyStore->Commit();
+ if (SUCCEEDED(hr))
+ {
+ ComPtr<IPersistFile> persistFile;
+ hr = shellLink.As(&persistFile);
+ if (SUCCEEDED(hr))
+ {
+ hr = persistFile->Save(shortcutPath, TRUE);
+ }
+ }
+ }
+ PropVariantClear(&appIdPropVar);
+ }
+ }
+ }
+ }
+ }
+ }
+ return hr;
+}
diff --git a/plugins/AddToStartMenu/src/stdafx.cxx b/plugins/AddToStartMenu/src/stdafx.cxx
new file mode 100644
index 0000000000..6fb37564b7
--- /dev/null
+++ b/plugins/AddToStartMenu/src/stdafx.cxx
@@ -0,0 +1,18 @@
+/*
+Copyright (C) 2012-15 Miranda NG project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h" \ No newline at end of file
diff --git a/plugins/AddToStartMenu/src/stdafx.h b/plugins/AddToStartMenu/src/stdafx.h
new file mode 100644
index 0000000000..99a26d1bac
--- /dev/null
+++ b/plugins/AddToStartMenu/src/stdafx.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include <Windows.h>
+#include <sal.h>
+#include <Psapi.h>
+
+#include <ObjBase.h>
+#include <ShObjIdl.h>
+#include <propvarutil.h>
+#include <functiondiscoverykeys.h>
+#include <intsafe.h>
+#include <guiddef.h>
+
+#include <wrl\client.h>
+#include <wrl\implements.h>
+
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_protocols.h>
+#include <m_protosvc.h>
+#include <m_langpack.h>
+#include <m_icolib.h>
+#include <m_extraicons.h>
+#include <m_message.h>
+#include <m_timezones.h>
+#include <m_genmenu.h>
+#include <m_clist.h>
+#include "Version.h"
+#include <strsafe.h>
+
+const wchar_t AppUserModelID[] = _T("MirandaNG");
+
+#define MODULENAME "AddToStartMenu"
+
+extern HINSTANCE g_hInst;
+
+
+INT_PTR Service(WPARAM, LPARAM);
+HRESULT TryCreateShortcut();
+HRESULT InstallShortcut(_In_z_ wchar_t *shortcutPath);
diff --git a/plugins/AddToStartMenu/src/version.h b/plugins/AddToStartMenu/src/version.h
new file mode 100644
index 0000000000..6245eaaa1a
--- /dev/null
+++ b/plugins/AddToStartMenu/src/version.h
@@ -0,0 +1,14 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 0
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "AddToStartMenu"
+#define __FILENAME "AddToStartMenu.dll"
+#define __DESCRIPTION "Add portable miranda shortcut to windows start menu."
+#define __AUTHOR "MikalaiR"
+#define __AUTHOREMAIL ""
+#define __AUTHORWEB "http://miranda-ng.org/p//"
+#define __COPYRIGHT "© 2015 Miranda NG Team"