From 2c73bb570b16ed862a3e28e263198273d4591074 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 30 Aug 2013 18:38:04 +0000 Subject: COM-related code rearranged git-svn-id: http://svn.miranda-ng.org/main/trunk@5889 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ShellExt/src/main.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'plugins/ShellExt/src/main.cpp') diff --git a/plugins/ShellExt/src/main.cpp b/plugins/ShellExt/src/main.cpp index 33d1ed0b83..e7a80c94a1 100644 --- a/plugins/ShellExt/src/main.cpp +++ b/plugins/ShellExt/src/main.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#include "shlcom.h" HINSTANCE hInst; int hLangpack; @@ -27,6 +28,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) hInst = hinstDLL; DisableThreadLibraryCalls(hinstDLL); + + extern bool VistaOrLater; + VistaOrLater = GetProcAddress( GetModuleHandleA("kernel32.dll"), "GetProductInfo") != NULL; } return TRUE; @@ -37,6 +41,43 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda return &pluginInfoEx; } +///////////////////////////////////////////////////////////////////////////////////////// +// exported functions + +const IID CLSID_ISHLCOM = { 0x72013A26, 0xA94C, 0x11d6, {0x85, 0x40, 0xA5, 0xE6, 0x29, 0x32, 0x71, 0x1D }}; + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) +{ + if (rclsid == CLSID_ISHLCOM) { + TClassFactoryRec *p = new TClassFactoryRec(); + HRESULT hr = p->QueryInterface(riid, ppv); + if ( FAILED(hr)) { + delete p; + return hr; + } + logA("DllGetClassObject succeeded\n"); + return S_OK; + } + + #ifdef LOG_ENABLED + RPC_CSTR szGuid; + UuidToStringA(&riid, &szGuid); + logA("DllGetClassObject {%08x-%04x-%04x-%08x%08x} failed\n", szGuid); + RpcStringFreeA(&szGuid); + #endif + + *ppv = NULL; + return CLASS_E_CLASSNOTAVAILABLE; +} + +STDAPI DllCanUnloadNow() +{ + logA("DllCanUnloadNow: %d %d\n", DllFactoryCount, DllObjectCount); + if (DllFactoryCount == 0 && DllObjectCount == 0) + return S_OK; + return S_FALSE; +} + ///////////////////////////////////////////////////////////////////////////////////////// struct HRegKey -- cgit v1.2.3