summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2012-06-22 20:03:58 +0000
committerKirill Volinsky <mataes2007@gmail.com>2012-06-22 20:03:58 +0000
commit5e8571847f3ccaa545a9fc1d26466f22ccce2d79 (patch)
tree316d11974da0296f8b944709a416a0ae6d72b818
parentbe99fef98132551217755324ec714af0f893056e (diff)
Autorun Unicode
git-svn-id: http://svn.miranda-ng.org/main/trunk@533 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/AutoRun/autorun.h18
-rw-r--r--plugins/AutoRun/autorun.rc1
-rw-r--r--plugins/AutoRun/autorun.vcxproj14
-rw-r--r--plugins/AutoRun/autorun.vcxproj.filters2
-rw-r--r--plugins/AutoRun/main.cpp76
-rw-r--r--plugins/AutoRun/resource.h2
6 files changed, 52 insertions, 61 deletions
diff --git a/plugins/AutoRun/autorun.h b/plugins/AutoRun/autorun.h
index 8c621e2546..4d0900fcf0 100644
--- a/plugins/AutoRun/autorun.h
+++ b/plugins/AutoRun/autorun.h
@@ -1,10 +1,17 @@
-#define IDD_OPT_AUTORUN 101
-#define IDC_AUTORUN 102
-
#define _CRT_SECURE_NO_WARNINGS
-
#define MIRANDA_VER 0x0A00
-#define SUB_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run"
+
+#include <windows.h>
+
+#include <newpluginapi.h>
+#include <m_langpack.h>
+#include <m_options.h>
+#include <m_database.h>
+#include <win2k.h>
+
+#include "resource.h"
+
+#define SUB_KEY _T("Software\\Microsoft\\Windows\\CurrentVersion\\Run")
#define ModuleName "Autorun"
// Plugin UUID for New plugin loader
@@ -14,4 +21,3 @@
#define MIID_AUTORUN {0xeb0465e2, 0xceee, 0x11db, { 0x83, 0xef, 0xc1, 0xbf, 0x55, 0xd8, 0x95, 0x93}}
HKEY ROOT_KEY = HKEY_CURRENT_USER;
-
diff --git a/plugins/AutoRun/autorun.rc b/plugins/AutoRun/autorun.rc
index b643834124..de10b17a40 100644
--- a/plugins/AutoRun/autorun.rc
+++ b/plugins/AutoRun/autorun.rc
@@ -7,7 +7,6 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include "autorun.h"
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/AutoRun/autorun.vcxproj b/plugins/AutoRun/autorun.vcxproj
index 5b6b16ed91..83efc59db1 100644
--- a/plugins/AutoRun/autorun.vcxproj
+++ b/plugins/AutoRun/autorun.vcxproj
@@ -25,21 +25,21 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
- <CharacterSet>MultiByte</CharacterSet>
+ <CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@@ -169,15 +169,15 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="main.c" />
- </ItemGroup>
- <ItemGroup>
<ClInclude Include="autorun.h" />
<ClInclude Include="resource.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="autorun.rc" />
</ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="main.cpp" />
+ </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
diff --git a/plugins/AutoRun/autorun.vcxproj.filters b/plugins/AutoRun/autorun.vcxproj.filters
index 82bd411933..15118eb49e 100644
--- a/plugins/AutoRun/autorun.vcxproj.filters
+++ b/plugins/AutoRun/autorun.vcxproj.filters
@@ -28,7 +28,7 @@
</ResourceCompile>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="main.c">
+ <ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/plugins/AutoRun/main.cpp b/plugins/AutoRun/main.cpp
index bf424c205e..478fc7aef5 100644
--- a/plugins/AutoRun/main.cpp
+++ b/plugins/AutoRun/main.cpp
@@ -1,19 +1,10 @@
-#define _CRT_SECURE_NO_WARNINGS
-
-#include <windows.h>
#include "autorun.h"
-#include "newpluginapi.h"
-#include "m_langpack.h"
-#include "m_options.h"
-#include "m_database.h"
-#pragma hdrstop
-
-
HINSTANCE hInst;
PLUGINLINK *pluginLink;
HANDLE hHookOptionInit = NULL;
int hLangpack;
+struct MM_INTERFACE mmi;
PLUGININFOEX pluginInfoEx=
{ // about plugin
@@ -31,25 +22,20 @@ PLUGININFOEX pluginInfoEx=
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
- // plugin entry point
- if (fdwReason == DLL_PROCESS_ATTACH)
- {
- hInst = hinstDLL;
- DisableThreadLibraryCalls(hinstDLL);
- }
+ hInst = hinstDLL;
return TRUE;
}
-void GetProfilePath(char *res)
+void GetProfilePath(TCHAR *res)
{
- char dbname[MAX_PATH], dbpath[MAX_PATH], exename[MAX_PATH];
- CallService(MS_DB_GETPROFILENAME,sizeof(dbname),(LPARAM)(char*) dbname);
- CallService(MS_DB_GETPROFILEPATH,sizeof(dbpath),(LPARAM)(char*) dbpath);
- GetModuleFileName(NULL,exename,sizeof(exename));
- lstrcat(dbpath,"\\");
- lstrcpyn(dbpath+lstrlen(dbpath),dbname,lstrlen(dbname)-3);
- strcat(dbpath, "\\");
- strcat(dbpath, dbname); // path + profile name
- wsprintf(res,"\"%s\" \"%s\"",exename, dbpath);
+ TCHAR dbname[MAX_PATH], dbpath[MAX_PATH], exename[MAX_PATH];
+ CallService(MS_DB_GETPROFILENAMET, SIZEOF(dbname), (LPARAM)(TCHAR*) dbname);
+ CallService(MS_DB_GETPROFILEPATHT, SIZEOF(dbpath), (LPARAM)(TCHAR*) dbpath);
+ GetModuleFileName(NULL,exename, SIZEOF(exename));
+ lstrcat(dbpath, _T("\\"));
+ lstrcpyn(dbpath + lstrlen(dbpath), dbname, lstrlen(dbname)-3);
+ lstrcat(dbpath, _T("\\"));
+ lstrcat(dbpath, dbname); // path + profile name
+ mir_sntprintf(res, lstrlen(exename) + lstrlen(dbpath) + 5, _T("\"%s\" \"%s\""), exename, dbpath);
}
static void SetAutorun(BOOL autorun)
@@ -59,35 +45,34 @@ static void SetAutorun(BOOL autorun)
switch (autorun)
{
case TRUE:
- if (RegCreateKeyEx(ROOT_KEY, SUB_KEY,0,NULL,0,KEY_CREATE_SUB_KEY|KEY_SET_VALUE,NULL,&hKey,&dw) == ERROR_SUCCESS)
+ if (RegCreateKeyEx(ROOT_KEY, SUB_KEY, 0, NULL, 0, KEY_CREATE_SUB_KEY|KEY_SET_VALUE,NULL,&hKey,&dw) == ERROR_SUCCESS)
{
- char result[MAX_PATH];
- GetProfilePath (result);
- RegSetValueEx(hKey,"MirandaIM",0,REG_SZ,result,lstrlen(result)+1);
+ TCHAR result[MAX_PATH];
+ GetProfilePath(result);
+ RegSetValueEx(hKey, _T("MirandaIM"), 0, REG_SZ, (BYTE*)result, lstrlen(result)+1);
RegCloseKey(hKey);
break;
}
case FALSE:
- if (RegOpenKey(ROOT_KEY,SUB_KEY,&hKey) == ERROR_SUCCESS)
+ if (RegOpenKey(ROOT_KEY, SUB_KEY, &hKey) == ERROR_SUCCESS)
{
- RegDeleteValue(hKey,"MirandaIM");
+ RegDeleteValue(hKey, _T("MirandaIM"));
RegCloseKey(hKey);
break;
}
}
}
-
static BOOL CmpCurrentAndRegistry()
{
HKEY hKey;
DWORD dwBufLen = MAX_PATH;
- char result[MAX_PATH], dbpath[MAX_PATH];
- GetProfilePath (result);
+ TCHAR result[MAX_PATH], dbpath[MAX_PATH];
+ GetProfilePath(result);
if (RegOpenKeyEx(ROOT_KEY, SUB_KEY, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
- if (RegQueryValueEx(hKey,"MirandaIM",NULL,NULL,(LPBYTE)dbpath,&dwBufLen) == ERROR_SUCCESS)
+ if (RegQueryValueEx(hKey, _T("MirandaIM"), NULL, NULL, (LPBYTE)dbpath, &dwBufLen) == ERROR_SUCCESS)
{
return (lstrcmpi(result,dbpath) == 0 ? TRUE : FALSE);
}
@@ -126,37 +111,36 @@ static INT_PTR CALLBACK DlgProcAutorunOpts(HWND hwndDlg, UINT msg, WPARAM wParam
return FALSE;
}
-
static int AutorunOptInitialise(WPARAM wParam,LPARAM lParam)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.cbSize = sizeof(odp);
odp.position = 100100000;
odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT_AUTORUN);
- odp.pszTitle = ModuleName;
- odp.pszGroup = LPGEN("Plugins");
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_AUTORUN);
+ odp.ptszTitle = _T(ModuleName);
+ odp.ptszGroup = LPGENT("Plugins");
odp.pfnDlgProc = DlgProcAutorunOpts;
odp.flags = ODPF_BOLDGROUPS;
Options_AddPage(wParam, &odp);
return 0;
}
-//==========================================================================
-__declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfoEx;
}
-
-int __declspec(dllexport) Load(PLUGINLINK *link)
+extern "C" __declspec(dllexport) int Load(PLUGINLINK *link)
{
pluginLink = link;
mir_getLP(&pluginInfoEx);
- hHookOptionInit = HookEvent(ME_OPT_INITIALISE,AutorunOptInitialise);
+ mir_getMMI(&mmi);
+ hHookOptionInit = HookEvent(ME_OPT_INITIALISE, AutorunOptInitialise);
return 0;
}
-int __declspec(dllexport) Unload(void)
+extern "C" __declspec(dllexport) int Unload(void)
{
if (hHookOptionInit)
UnhookEvent(hHookOptionInit);
diff --git a/plugins/AutoRun/resource.h b/plugins/AutoRun/resource.h
index c5b53f192c..75fd39b582 100644
--- a/plugins/AutoRun/resource.h
+++ b/plugins/AutoRun/resource.h
@@ -2,6 +2,8 @@
// Microsoft Developer Studio generated include file.
// Used by autorun.rc
//
+#define IDD_OPT_AUTORUN 101
+#define IDC_AUTORUN 102
// Next default values for new objects
//