aboutsummaryrefslogtreecommitdiff
path: root/src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp')
-rw-r--r--src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp b/src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp
new file mode 100644
index 00000000..1a9fcb32
--- /dev/null
+++ b/src/test/msi/TestData/ComPlusExtensionTests/Components/TestComponentNative/TestComponentNative.cpp
@@ -0,0 +1,74 @@
1// TestComponentNative.cpp : Implementation of DLL Exports.
2
3
4#include "pch.h"
5#include "framework.h"
6#include "resource.h"
7#include "TestComponentNative_i.h"
8#include "dllmain.h"
9
10
11using namespace ATL;
12
13// Used to determine whether the DLL can be unloaded by OLE.
14_Use_decl_annotations_
15STDAPI DllCanUnloadNow(void)
16{
17 return _AtlModule.DllCanUnloadNow();
18}
19
20// Returns a class factory to create an object of the requested type.
21_Use_decl_annotations_
22STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
23{
24 return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
25}
26
27// DllRegisterServer - Adds entries to the system registry.
28_Use_decl_annotations_
29STDAPI DllRegisterServer(void)
30{
31 // registers object, typelib and all interfaces in typelib
32 HRESULT hr = _AtlModule.DllRegisterServer();
33 return hr;
34}
35
36// DllUnregisterServer - Removes entries from the system registry.
37_Use_decl_annotations_
38STDAPI DllUnregisterServer(void)
39{
40 HRESULT hr = _AtlModule.DllUnregisterServer();
41 return hr;
42}
43
44// DllInstall - Adds/Removes entries to the system registry per user per machine.
45STDAPI DllInstall(BOOL bInstall, _In_opt_ LPCWSTR pszCmdLine)
46{
47 HRESULT hr = E_FAIL;
48 static const wchar_t szUserSwitch[] = L"user";
49
50 if (pszCmdLine != nullptr)
51 {
52 if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
53 {
54 ATL::AtlSetPerUserRegistration(true);
55 }
56 }
57
58 if (bInstall)
59 {
60 hr = DllRegisterServer();
61 if (FAILED(hr))
62 {
63 DllUnregisterServer();
64 }
65 }
66 else
67 {
68 hr = DllUnregisterServer();
69 }
70
71 return hr;
72}
73
74