source: trunk/Utilities/VbsEvents/VbsEvents.cpp @ 937

Last change on this file since 937 was 79, checked in by roman, 10 years ago
  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1// VbsEvents.cpp : Implementation of DLL Exports.
2
3
4#include "stdafx.h"
5#include "resource.h"
6#include "VbsEvents_i.h"
7#include "dllmain.h"
8
9
10// Used to determine whether the DLL can be unloaded by OLE.
11STDAPI DllCanUnloadNow(void)
12{
13                        return _AtlModule.DllCanUnloadNow();
14        }
15
16// Returns a class factory to create an object of the requested type.
17STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
18{
19                return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
20}
21
22// DllRegisterServer - Adds entries to the system registry.
23STDAPI DllRegisterServer(void)
24{
25        // registers object, typelib and all interfaces in typelib
26        HRESULT hr = _AtlModule.DllRegisterServer();
27                return hr;
28}
29
30// DllUnregisterServer - Removes entries from the system registry.
31STDAPI DllUnregisterServer(void)
32{
33        HRESULT hr = _AtlModule.DllUnregisterServer();
34                return hr;
35}
36
37// DllInstall - Adds/Removes entries to the system registry per user per machine.
38STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
39{
40        HRESULT hr = E_FAIL;
41        static const wchar_t szUserSwitch[] = L"user";
42
43        if (pszCmdLine != NULL)
44        {
45                if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
46                {
47                        ATL::AtlSetPerUserRegistration(true);
48                }
49        }
50
51        if (bInstall)
52        {       
53                hr = DllRegisterServer();
54                if (FAILED(hr))
55                {
56                        DllUnregisterServer();
57                }
58        }
59        else
60        {
61                hr = DllUnregisterServer();
62        }
63
64        return hr;
65}
66
67
Note: See TracBrowser for help on using the repository browser.