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