mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-12 15:39:33 +08:00
74 lines
2.0 KiB
C++
74 lines
2.0 KiB
C++
|
// dllmain.cpp : Defines the entry point for the DLL application.
|
||
|
#include "pch.h"
|
||
|
#include "ClassFactory.h"
|
||
|
|
||
|
HINSTANCE g_hInst = NULL;
|
||
|
long g_cDllRef = 0;
|
||
|
|
||
|
// {77257004-6F25-4521-B602-50ECC6EC62A6}
|
||
|
static const GUID CLSID_StlThumbnailProvider = { 0x77257004, 0x6f25, 0x4521, { 0xb6, 0x2, 0x50, 0xec, 0xc6, 0xec, 0x62, 0xa6 } };
|
||
|
|
||
|
BOOL APIENTRY DllMain(HMODULE hModule,
|
||
|
DWORD ul_reason_for_call,
|
||
|
LPVOID lpReserved)
|
||
|
{
|
||
|
switch (ul_reason_for_call)
|
||
|
{
|
||
|
case DLL_PROCESS_ATTACH:
|
||
|
g_hInst = hModule;
|
||
|
DisableThreadLibraryCalls(hModule);
|
||
|
break;
|
||
|
case DLL_THREAD_ATTACH:
|
||
|
case DLL_THREAD_DETACH:
|
||
|
case DLL_PROCESS_DETACH:
|
||
|
break;
|
||
|
}
|
||
|
return TRUE;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// FUNCTION: DllGetClassObject
|
||
|
//
|
||
|
// PURPOSE: Create the class factory and query to the specific interface.
|
||
|
//
|
||
|
// PARAMETERS:
|
||
|
// * rclsid - The CLSID that will associate the correct data and code.
|
||
|
// * riid - A reference to the identifier of the interface that the caller
|
||
|
// is to use to communicate with the class object.
|
||
|
// * ppv - The address of a pointer variable that receives the interface
|
||
|
// pointer requested in riid. Upon successful return, *ppv contains the
|
||
|
// requested interface pointer. If an error occurs, the interface pointer
|
||
|
// is NULL.
|
||
|
//
|
||
|
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void** ppv)
|
||
|
{
|
||
|
HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;
|
||
|
|
||
|
if (IsEqualCLSID(CLSID_StlThumbnailProvider, rclsid))
|
||
|
{
|
||
|
hr = E_OUTOFMEMORY;
|
||
|
|
||
|
ClassFactory* pClassFactory = new ClassFactory();
|
||
|
if (pClassFactory)
|
||
|
{
|
||
|
hr = pClassFactory->QueryInterface(riid, ppv);
|
||
|
pClassFactory->Release();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return hr;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// FUNCTION: DllCanUnloadNow
|
||
|
//
|
||
|
// PURPOSE: Check if we can unload the component from the memory.
|
||
|
//
|
||
|
// NOTE: The component can be unloaded from the memory when its reference
|
||
|
// count is zero (i.e. nobody is still using the component).
|
||
|
//
|
||
|
STDAPI DllCanUnloadNow(void)
|
||
|
{
|
||
|
return g_cDllRef > 0 ? S_FALSE : S_OK;
|
||
|
}
|