source: trunk/Utilities/Miscellaneous/ComIsolation01/Server/Server.cpp @ 531

Last change on this file since 531 was 531, checked in by roman, 8 years ago
File size: 1.7 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2015
3// Created by Roman Ryltsov roman@alax.info
4//
5// A permission to use the source code is granted as long as reference to
6// source website http://alax.info is retained.
7
8#include "stdafx.h"
9#include "resource.h"
10#include "Server_i.h"
11#include "dllmain.h"
12
13using namespace ATL;
14
15// Used to determine whether the DLL can be unloaded by OLE.
16STDAPI DllCanUnloadNow(void)
17{
18                        return _AtlModule.DllCanUnloadNow();
19        }
20
21// Returns a class factory to create an object of the requested type.
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.
28STDAPI DllRegisterServer(void)
29{
30        // registers object, typelib and all interfaces in typelib
31        HRESULT hr = _AtlModule.DllRegisterServer();
32                return hr;
33}
34
35// DllUnregisterServer - Removes entries from the system registry.
36STDAPI DllUnregisterServer(void)
37{
38        HRESULT hr = _AtlModule.DllUnregisterServer();
39                return hr;
40}
41
42// DllInstall - Adds/Removes entries to the system registry per user per machine.
43STDAPI DllInstall(BOOL bInstall, _In_opt_  LPCWSTR pszCmdLine)
44{
45        HRESULT hr = E_FAIL;
46        static const wchar_t szUserSwitch[] = L"user";
47
48        if (pszCmdLine != NULL)
49        {
50                if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
51                {
52                        ATL::AtlSetPerUserRegistration(true);
53                }
54        }
55
56        if (bInstall)
57        {       
58                hr = DllRegisterServer();
59                if (FAILED(hr))
60                {
61                        DllUnregisterServer();
62                }
63        }
64        else
65        {
66                hr = DllUnregisterServer();
67        }
68
69        return hr;
70}
71
72
Note: See TracBrowser for help on using the repository browser.