From b172c4bbc75cdad0e8ccd22292aa671ba43cac45 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 Apr 2018 18:14:33 +0300 Subject: PLUGIN<> to half-automatically calculate the dll's g_hInstance and pass it inside --- plugins/GmailNotifier/src/main.cpp | 14 +++++--------- plugins/GmailNotifier/src/options.cpp | 2 +- plugins/GmailNotifier/src/stdafx.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) (limited to 'plugins/GmailNotifier') diff --git a/plugins/GmailNotifier/src/main.cpp b/plugins/GmailNotifier/src/main.cpp index 9dccc5965d..945ab5984d 100644 --- a/plugins/GmailNotifier/src/main.cpp +++ b/plugins/GmailNotifier/src/main.cpp @@ -11,7 +11,7 @@ There is no warranty. #include "version.h" CLIST_INTERFACE *pcli; -HINSTANCE hInst; +HINSTANCE g_hInstance; int hLangpack; UINT hTimer; HANDLE hMirandaStarted, hOptionsInitial; @@ -56,12 +56,6 @@ INT_PTR GetName(WPARAM wParam, LPARAM lParam) return 0; } -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) -{ - hInst = hinstDLL; - return TRUE; -} - void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD) { PluginMenuCommand(0, 0); @@ -170,12 +164,14 @@ extern "C" int __declspec(dllexport) Unload(void) ///////////////////////////////////////////////////////////////////////////////////////// -struct CMPlugin : public CMPluginBase +struct CMPlugin : public PLUGIN { CMPlugin() : - CMPluginBase(MODULE_NAME) + PLUGIN(MODULE_NAME) { RegisterProtocol(PROTOTYPE_VIRTUAL); } } g_plugin; + +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; diff --git a/plugins/GmailNotifier/src/options.cpp b/plugins/GmailNotifier/src/options.cpp index cc2bd0ffa9..4aafb314f6 100644 --- a/plugins/GmailNotifier/src/options.cpp +++ b/plugins/GmailNotifier/src/options.cpp @@ -272,7 +272,7 @@ int OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = { 0 }; odp.position = -790000000; - odp.hInstance = hInst; + odp.hInstance = g_hInstance; odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); odp.szTitle.a = LPGEN("GmailNotifier"); odp.szGroup.a = LPGEN("Network"); diff --git a/plugins/GmailNotifier/src/stdafx.h b/plugins/GmailNotifier/src/stdafx.h index 78d5c08275..c098816cef 100644 --- a/plugins/GmailNotifier/src/stdafx.h +++ b/plugins/GmailNotifier/src/stdafx.h @@ -73,7 +73,7 @@ struct optionSettings extern OBJLIST g_accs; extern optionSettings opt; -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; extern HNETLIBUSER hNetlibUser; extern UINT hTimer; extern short ID_STATUS_NONEW; -- cgit v1.2.3