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 --- protocols/VKontakte/src/main.cpp | 21 +++------------------ protocols/VKontakte/src/misc.cpp | 2 +- protocols/VKontakte/src/stdafx.h | 2 +- protocols/VKontakte/src/vk.h | 2 +- protocols/VKontakte/src/vk_proto.h | 11 ++++++++++- 5 files changed, 16 insertions(+), 22 deletions(-) (limited to 'protocols/VKontakte/src') diff --git a/protocols/VKontakte/src/main.cpp b/protocols/VKontakte/src/main.cpp index 71e8ddd3cd..01a6dfb66d 100644 --- a/protocols/VKontakte/src/main.cpp +++ b/protocols/VKontakte/src/main.cpp @@ -18,7 +18,8 @@ along with this program. If not, see . #include "stdafx.h" #include "version.h" -HINSTANCE hInst; +CMPlugin g_plugin; +HINSTANCE g_hInstance; int hLangpack; CLIST_INTERFACE *pcli; @@ -38,11 +39,7 @@ PLUGININFOEX pluginInfo = ///////////////////////////////////////////////////////////////////////////////////////// -BOOL WINAPI DllMain(HINSTANCE hModule, DWORD, LPVOID) -{ - hInst = hModule; - return TRUE; -} +extern "C" _pfnCrtInit _pRawDllMain = &CMPlugin::RawDllMain; extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { @@ -70,15 +67,3 @@ extern "C" int __declspec(dllexport) Unload(void) { return 0; } - -///////////////////////////////////////////////////////////////////////////////////////// - -struct CMPlugin : public ACCPROTOPLUGIN -{ - CMPlugin() : - ACCPROTOPLUGIN("VKontakte") - { - SetUniqueId("ID"); - } -} - g_plugin; diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index 2f3aeca9c7..1b18bc382b 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -79,7 +79,7 @@ static IconItem iconList[] = void InitIcons() { - Icon_Register(hInst, LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte"); + Icon_Register(g_hInstance, LPGEN("Protocols") "/" LPGEN("VKontakte"), iconList, _countof(iconList), "VKontakte"); } HANDLE GetIconHandle(int iCommand) diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index da91ad030d..e60368369e 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -57,7 +57,7 @@ along with this program. If not, see . #include "win2k.h" -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; #include "resource.h" #include "vk.h" diff --git a/protocols/VKontakte/src/vk.h b/protocols/VKontakte/src/vk.h index 4fd3060912..b40f8980ba 100644 --- a/protocols/VKontakte/src/vk.h +++ b/protocols/VKontakte/src/vk.h @@ -103,7 +103,7 @@ along with this program. If not, see . struct CVkProto; extern LIST vk_Instances; extern mir_cs csInstances; -extern HINSTANCE hInst; +extern HINSTANCE g_hInstance; LPCSTR findHeader(NETLIBHTTPREQUEST *hdr, LPCSTR szField); bool wlstrstr(wchar_t *_s1, wchar_t *_s2); diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 8b7abdbb8a..5c050cf2a4 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -399,4 +399,13 @@ private: void SetChatStatus(MCONTACT hContact, int iStatus); CVkChatInfo* GetChatById(LPCWSTR pwszId); INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM); -}; \ No newline at end of file +}; + +struct CMPlugin : public ACCPROTOPLUGIN +{ + CMPlugin() : + ACCPROTOPLUGIN("VKontakte") + { + SetUniqueId("ID"); + } +}; -- cgit v1.2.3