source: trunk/Utilities/Miscellaneous/RegFreeComPictureDisp/Server/Server.cpp @ 793

Last change on this file since 793 was 793, checked in by roman, 5 years ago
  • Property svn:mime-type set to application/octet-stream
File size: 3.1 KB
Line 
1// Server.cpp : Implementation of DLL Exports.
2
3
4#include "stdafx.h"
5#include "resource.h"
6#include "Server_i.h"
7#include "dllmain.h"
8
9
10using namespace ATL;
11
12// Used to determine whether the DLL can be unloaded by OLE.
13_Use_decl_annotations_
14STDAPI DllCanUnloadNow(void)
15{
16        return _AtlModule.DllCanUnloadNow();
17}
18
19// Returns a class factory to create an object of the requested type.
20_Use_decl_annotations_
21STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID* ppv)
22{
23        return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
24}
25
26// DllRegisterServer - Adds entries to the system registry.
27_Use_decl_annotations_
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.
36_Use_decl_annotations_
37STDAPI DllUnregisterServer(void)
38{
39        HRESULT hr = _AtlModule.DllUnregisterServer();
40        return hr;
41}
42
43// DllInstall - Adds/Removes entries to the system registry per user per machine.
44STDAPI DllInstall(BOOL bInstall, _In_opt_  LPCWSTR pszCmdLine)
45{
46        HRESULT hr = E_FAIL;
47        static const wchar_t szUserSwitch[] = L"user";
48
49        if (pszCmdLine != NULL)
50        {
51                if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
52                {
53                        ATL::AtlSetPerUserRegistration(true);
54                }
55        }
56
57        if (bInstall)
58        {
59                hr = DllRegisterServer();
60                if (FAILED(hr))
61                {
62                        DllUnregisterServer();
63                }
64        }
65        else
66        {
67                hr = DllUnregisterServer();
68        }
69
70        return hr;
71}
72
73
Note: See TracBrowser for help on using the repository browser.