home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / surpriz / MSRMesh-VirtualWIFI.MSI / dllmain.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-06-24  |  2.4 KB  |  112 lines

  1. /*
  2.  * Author   : Ranveer Chandra
  3.  * Directory: VirtualWiFi_Root\notifyob
  4.  * File Name: dllmain.cpp
  5.  * Purpose  : Main entry points into the DLL
  6.  */
  7.  
  8. #include <windows.h>
  9. #include <shellapi.h>
  10. #include <shlobj.h>
  11.  
  12. #include <atlbase.h>
  13. extern CComModule _Module;  // required by atlcom.h
  14. #include <atlcom.h>
  15. #include <devguid.h>
  16.  
  17. #include "notify.h"
  18. #include "notifyn_i.c"
  19.  
  20.  
  21. CComModule _Module;
  22.  
  23. BEGIN_OBJECT_MAP(ObjectMap)
  24.     OBJECT_ENTRY(CLSID_CMuxNotify, CMuxNotify)
  25. END_OBJECT_MAP()
  26.  
  27.  
  28.  
  29.  
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // DLL Entry Point
  33.  
  34. extern "C"
  35. BOOL WINAPI DllMain (HINSTANCE hInstance,
  36.                      DWORD dwReason,
  37.                      LPVOID /*lpReserved*/)
  38. {
  39.     TraceMsg( L"-->DllMain.\n");
  40.  
  41.     if (dwReason == DLL_PROCESS_ATTACH) {
  42.  
  43.         TraceMsg( L"   Reason: Attach.\n");
  44.  
  45.         _Module.Init(ObjectMap, hInstance);
  46.  
  47.         DisableThreadLibraryCalls(hInstance);
  48.     }
  49.     else if (dwReason == DLL_PROCESS_DETACH) {
  50.  
  51.         TraceMsg( L"   Reason: Detach.\n");
  52.  
  53.            _Module.Term();
  54.     }
  55.  
  56.     TraceMsg( L"<--DllMain.\n");
  57.  
  58.     return TRUE;
  59. }
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // Used to determine whether the DLL can be unloaded by OLE
  63.  
  64. STDAPI DllCanUnloadNow(void)
  65. {
  66.     HRESULT hr;
  67.  
  68.     TraceMsg( L"-->DllCanUnloadNow.\n");
  69.  
  70.     hr = (_Module.GetLockCount() == 0) ? S_OK : S_FALSE;
  71.  
  72.     TraceMsg( L"-->DllCanUnloadNow(HRESULT = %x).\n",
  73.             hr );
  74.  
  75.     return hr;  
  76. }
  77.  
  78. /////////////////////////////////////////////////////////////////////////////
  79. // Returns a class factory to create an object of the requested type
  80.  
  81. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  82. {
  83.     TraceMsg( L"-->DllGetClassObject.\n");
  84.  
  85.     return _Module.GetClassObject(rclsid, riid, ppv);
  86. }
  87.  
  88. /////////////////////////////////////////////////////////////////////////////
  89. // DllRegisterServer - Adds entries to the system registry
  90.  
  91. STDAPI DllRegisterServer(void)
  92. {
  93.     // Registers object, typelib and all interfaces in typelib
  94.  
  95.     TraceMsg( L"-->DllRegisterServer.\n");
  96.  
  97.     return _Module.RegisterServer(TRUE);
  98. }
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // DllUnregisterServer - Removes entries from the system registry
  102.  
  103. STDAPI DllUnregisterServer(void)
  104. {
  105.     TraceMsg( L"-->DllUnregisterServer.\n");
  106.  
  107.     _Module.UnregisterServer();
  108.  
  109.     return S_OK;
  110. }
  111.  
  112.