1 //////////////////////////////////////////////////////////////////////////
2 //
3 // dllmain.cpp
4 //
5 // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
6 // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
7 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
8 // PARTICULAR PURPOSE.
9 //
10 // Copyright (c) Microsoft Corporation. All rights reserved.
11 //
12 //////////////////////////////////////////////////////////////////////////
13 
14 #include <initguid.h>
15 #include "OcvTransform.h"
16 
17 using namespace Microsoft::WRL;
18 
19 namespace Microsoft { namespace Samples {
20     ActivatableClass(OcvImageManipulations);
21 }}
22 
DllMain(_In_ HINSTANCE hInstance,_In_ DWORD dwReason,_In_opt_ LPVOID lpReserved)23 BOOL WINAPI DllMain( _In_ HINSTANCE hInstance, _In_ DWORD dwReason, _In_opt_ LPVOID lpReserved )
24 {
25     if( DLL_PROCESS_ATTACH == dwReason )
26     {
27         //
28         //  Don't need per-thread callbacks
29         //
30         DisableThreadLibraryCalls( hInstance );
31 
32         Module<InProc>::GetModule().Create();
33     }
34     else if( DLL_PROCESS_DETACH == dwReason )
35     {
36         Module<InProc>::GetModule().Terminate();
37     }
38 
39     return TRUE;
40 }
41 
DllGetActivationFactory(_In_ HSTRING activatibleClassId,_Outptr_ IActivationFactory ** factory)42 HRESULT WINAPI DllGetActivationFactory( _In_ HSTRING activatibleClassId, _Outptr_ IActivationFactory** factory )
43 {
44     auto &module = Microsoft::WRL::Module< Microsoft::WRL::InProc >::GetModule();
45     return module.GetActivationFactory( activatibleClassId, factory );
46 }
47 
DllCanUnloadNow()48 HRESULT WINAPI DllCanUnloadNow()
49 {
50     auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
51     return (module.Terminate()) ? S_OK : S_FALSE;
52 }
53 
DllGetClassObject(_In_ REFCLSID rclsid,_In_ REFIID riid,_Outptr_ LPVOID FAR * ppv)54 STDAPI DllGetClassObject( _In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR* ppv )
55 {
56     auto &module = Microsoft::WRL::Module<Microsoft::WRL::InProc>::GetModule();
57     return module.GetClassObject( rclsid, riid, ppv );
58 }
59