CFugue
CFugueDLL.cpp
1 /*
2  This is part of CFugue, a C++ Runtime for MIDI Score Programming
3  Copyright (C) 2009 Gopalakrishna Palem
4 
5  For links to further information, or to contact the author,
6  see <http://musicnote.sourceforge.net/>.
7 */
8 
9 // CFugueDLL.cpp : Implementation of DLL Exports.
10 
11 
12 #include "stdafx.h"
13 #include "resource.h"
14 //#include "CFugueDLL_i.h"
15 #include "dllmain.h"
16 #include "dlldatax.h"
17 
18 // Used to determine whether the DLL can be unloaded by OLE
19 STDAPI DllCanUnloadNow(void)
20 {
21 #ifdef _MERGE_PROXYSTUB
22  HRESULT hr = PrxDllCanUnloadNow();
23  if (hr != S_OK)
24  return hr;
25 #endif
26  return _AtlModule.DllCanUnloadNow();
27 }
28 
29 
30 // Returns a class factory to create an object of the requested type
31 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
32 {
33 #ifdef _MERGE_PROXYSTUB
34  if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
35  return S_OK;
36 #endif
37  return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
38 }
39 
40 
41 // DllRegisterServer - Adds entries to the system registry
42 STDAPI DllRegisterServer(void)
43 {
44  // registers object, typelib and all interfaces in typelib
45  HRESULT hr = _AtlModule.DllRegisterServer();
46 #ifdef _MERGE_PROXYSTUB
47  if (FAILED(hr))
48  return hr;
49  hr = PrxDllRegisterServer();
50 #endif
51  return hr;
52 }
53 
54 
55 // DllUnregisterServer - Removes entries from the system registry
56 STDAPI DllUnregisterServer(void)
57 {
58  HRESULT hr = _AtlModule.DllUnregisterServer();
59 #ifdef _MERGE_PROXYSTUB
60  if (FAILED(hr))
61  return hr;
62  hr = PrxDllRegisterServer();
63  if (FAILED(hr))
64  return hr;
65  hr = PrxDllUnregisterServer();
66 #endif
67  return hr;
68 }
69 
70 // DllInstall - Adds/Removes entries to the system registry per user
71 // per machine.
72 STDAPI DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
73 {
74  HRESULT hr = E_FAIL;
75  static const wchar_t szUserSwitch[] = L"user";
76 
77  if (pszCmdLine != NULL)
78  {
79  if (_wcsnicmp(pszCmdLine, szUserSwitch, _countof(szUserSwitch)) == 0)
80  {
81  AtlSetPerUserRegistration(true);
82  }
83  }
84 
85  if (bInstall)
86  {
87  hr = DllRegisterServer();
88  if (FAILED(hr))
89  {
90  DllUnregisterServer();
91  }
92  }
93  else
94  {
95  hr = DllUnregisterServer();
96  }
97 
98  return hr;
99 }
100 
101 

CFugue, the C++ Music Programming Library © Copyright 2009 Cenacle Research India Private Limited Gopalakrishna Palem