Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.2 KiB

  1. /*++
  2. (c) 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. HSMShell.cpp
  5. Abstract:
  6. Base file for HSM shell extensions
  7. Author:
  8. Art Bragg [abragg] 04-Aug-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. CComModule _Module;
  13. BEGIN_OBJECT_MAP(ObjectMap)
  14. OBJECT_ENTRY(CLSID_PrDrive, CPrDrive)
  15. END_OBJECT_MAP()
  16. class CHSMShellApp : public CWinApp
  17. {
  18. public:
  19. virtual BOOL InitInstance();
  20. virtual int ExitInstance();
  21. };
  22. CHSMShellApp theApp;
  23. BOOL CHSMShellApp::InitInstance()
  24. {
  25. _Module.Init(ObjectMap, m_hInstance);
  26. return CWinApp::InitInstance();
  27. }
  28. int CHSMShellApp::ExitInstance()
  29. {
  30. _Module.Term();
  31. return CWinApp::ExitInstance();
  32. }
  33. /////////////////////////////////////////////////////////////////////////////
  34. // DLL Entry Point
  35. extern "C"
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Used to determine whether the DLL can be unloaded by OLE
  38. STDAPI DllCanUnloadNow(void)
  39. {
  40. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  41. LONG lockCount = _Module.GetLockCount(); // For debugging
  42. return( lockCount == 0 ) ? S_OK : S_FALSE;
  43. }
  44. /////////////////////////////////////////////////////////////////////////////
  45. // Returns a class factory to create an object of the requested type
  46. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  47. {
  48. return _Module.GetClassObject(rclsid, riid, ppv);
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // DllRegisterServer - Adds entries to the system registry
  52. STDAPI DllRegisterServer(void)
  53. {
  54. HRESULT hr;
  55. // registers object
  56. hr = CoInitialize( 0 );
  57. if (SUCCEEDED(hr)) {
  58. hr = _Module.RegisterServer( FALSE );
  59. CoUninitialize( );
  60. }
  61. return( hr );
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DllUnregisterServer - Removes entries from the system registry
  65. STDAPI DllUnregisterServer(void)
  66. {
  67. HRESULT hr;
  68. hr = CoInitialize( 0 );
  69. if (SUCCEEDED(hr)) {
  70. _Module.UnregisterServer();
  71. CoUninitialize( );
  72. hr = S_OK;
  73. }
  74. return( hr );
  75. }