home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / AEDMOWiz.awx / TEMPLATE / DSMOTEMPLATE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-11  |  3.3 KB  |  119 lines

  1. //------------------------------------------------------------------------------
  2. // File: $$DLL_NAME$$.cpp
  3. //
  4. // Desc: Audio Effect DMO Wizard generated code - Implementation of DLL Exports.
  5. //
  6. // Copyright (c) Microsoft Corporation.  All rights reserved.
  7. //------------------------------------------------------------------------------
  8.  
  9.  
  10. #include "stdafx.h"
  11.  
  12. #define _ATL_FREE_THREADED
  13. #define _ATL_STATIC_REGISTRY
  14.  
  15. #include <atlbase.h>
  16. //You may derive a class from CComModule and use it if you want to override
  17. //something, but do not change the name of _Module
  18. extern CComModule _Module;
  19. #include <atlcom.h>
  20. #include <atlctl.h>
  21. #include <statreg.h>
  22. #include <statreg.cpp>
  23. #include <atlimpl.cpp>
  24.  
  25. #include "resource.h"
  26.  
  27. #define FIX_LOCK_NAME
  28. #include <dmo.h>
  29. #include <dmoimpl.h>
  30. $$IF(SUPPORT_DS_IMEDPARAM || SUPPORT_DS_DMP)
  31. #include "param.h"        // (param.h must come before uuids to avoid redefinitions)
  32. $$ENDIF
  33.  
  34. #include "$$CLASS_NAME$$.h"
  35. $$IF(SUPPORT_DS_DMP)
  36. #include "$$CLASS_NAME$$Prop.h"
  37. $$ENDIF
  38.  
  39. CComModule _Module;
  40.  
  41. BEGIN_OBJECT_MAP(ObjectMap)
  42. OBJECT_ENTRY(CLSID_$$DSDMO_DEFINE$$, $$CLASS_NAME$$)
  43. $$IF(SUPPORT_DS_DMP)
  44. OBJECT_ENTRY(CLSID_$$DSDMO_DEFINE$$PROP, $$CLASS_NAME$$Prop)
  45. $$ENDIF
  46. END_OBJECT_MAP()
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // DLL Entry Point
  50.  
  51. extern "C"
  52. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  53. {
  54.     if (DLL_PROCESS_ATTACH == dwReason)
  55.     {
  56.         _Module.Init(ObjectMap, hInstance);
  57.         DisableThreadLibraryCalls(hInstance);
  58.     }
  59.     else if (DLL_PROCESS_DETACH == dwReason)
  60.         _Module.Term();
  61.     return TRUE;    // ok
  62. }
  63.  
  64. /////////////////////////////////////////////////////////////////////////////
  65. // Used to determine whether the DLL can be unloaded by OLE
  66.  
  67. STDAPI DllCanUnloadNow(void)
  68. {
  69.     return (0 == _Module.GetLockCount()) ? S_OK : S_FALSE;
  70. }
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // Returns a class factory to create an object of the requested type
  74.  
  75. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  76. {
  77.     return _Module.GetClassObject(rclsid, riid, ppv);
  78. }
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // DllRegisterServer - Adds entries to the system registry
  82.  
  83. STDAPI DllRegisterServer(void)
  84. {
  85.     // Register ourself as a PCM audio effect DMO
  86.     DMO_PARTIAL_MEDIATYPE mt;
  87.     mt.type    = MEDIATYPE_Audio;
  88. $$IF(PROCESS_MEDIATYPE_16BIT_PCM || PROCESS_MEDIATYPE_8BIT_PCM)    // If processes PCM
  89.     mt.subtype = MEDIASUBTYPE_PCM;
  90. $$ELIF(PROCESS_MEDIATYPE_FLOAT)                                    // If processes only float
  91.     mt.subtype = MEDIASUBTYPE_IEEE_FLOAT;
  92. $$ELSE    // If neither, set to PCM as it's DirectSound's default
  93.     mt.subtype = MEDIASUBTYPE_PCM;
  94. $$ENDIF
  95.  
  96.     HRESULT hr = DMORegister(L"$$DSDMO_NAME$$",
  97.                              CLSID_$$DSDMO_DEFINE$$, 
  98.                              DMOCATEGORY_AUDIO_EFFECT,
  99.                              0,
  100.                              1,
  101.                              &mt,
  102.                              1,
  103.                              &mt);
  104.  
  105.     // registers object
  106.     return _Module.RegisterServer();
  107. }
  108.  
  109. /////////////////////////////////////////////////////////////////////////////
  110. // DllUnregisterServer - Removes entries from the system registry
  111.  
  112. STDAPI DllUnregisterServer(void)
  113. {
  114.        DMOUnregister(CLSID_$$DSDMO_DEFINE$$, DMOCATEGORY_AUDIO_EFFECT);
  115.     return _Module.UnregisterServer();
  116. }
  117.  
  118.  
  119.