home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DMO / GargleDMO / GargleDMO.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  2.6 KB  |  94 lines

  1. //------------------------------------------------------------------------------
  2. // File: GargleDMO.cpp
  3. //
  4. // Desc: DirectShow sample code - implementation of DLL exports.
  5. //
  6. // Copyright (c) 2000-2001 Microsoft Corporation.  All rights reserved.
  7. //------------------------------------------------------------------------------
  8.  
  9.  
  10. // Note: Proxy/Stub Information
  11. //      To build a separate proxy/stub DLL, 
  12. //      run nmake -f GargleDMOps.mk in the project directory.
  13.  
  14. #include "stdafx.h"
  15. #include "resource.h"
  16. #define FIX_LOCK_NAME
  17. #include <dmo.h>
  18. #include <dmobase.h>
  19. #include <param.h>
  20. #include "Gargle.h"
  21. #include "GargDMOProp.h"
  22.  
  23. CComModule _Module;
  24.  
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_Gargle, CGargle)
  27. OBJECT_ENTRY(CLSID_GargDMOProp, CGargDMOProp)
  28. END_OBJECT_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // DLL Entry Point
  32.  
  33. extern "C"
  34. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  35. {
  36.     if (dwReason == DLL_PROCESS_ATTACH)
  37.     {
  38.         _Module.Init(ObjectMap, hInstance);
  39.         DisableThreadLibraryCalls(hInstance);
  40.     }
  41.     else if (dwReason == DLL_PROCESS_DETACH)
  42.         _Module.Term();
  43.     return TRUE;    // ok
  44. }
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Used to determine whether the DLL can be unloaded by OLE
  48.  
  49. STDAPI DllCanUnloadNow(void)
  50. {
  51.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Returns a class factory to create an object of the requested type
  56.  
  57. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  58. {
  59.     return _Module.GetClassObject(rclsid, riid, ppv);
  60. }
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // DllRegisterServer - Adds entries to the system registry
  64.  
  65. STDAPI DllRegisterServer(void)
  66. {
  67.     // Register ourselves as a pcm audio effects DMO
  68.     DMO_PARTIAL_MEDIATYPE mt;
  69.     mt.type    = MEDIATYPE_Audio;
  70.     mt.subtype = MEDIASUBTYPE_PCM;
  71.  
  72.     DMORegister(L"Gargle DMO Sample", 
  73.                 CLSID_Gargle, 
  74.                 DMOCATEGORY_AUDIO_EFFECT,
  75.                 0,
  76.                 1,
  77.                 &mt,
  78.                 1,
  79.                 &mt);
  80.  
  81.     // registers object, but we're not using a typelib
  82.     return _Module.RegisterServer(FALSE);
  83. }
  84.  
  85. /////////////////////////////////////////////////////////////////////////////
  86. // DllUnregisterServer - Removes entries from the system registry
  87.  
  88. STDAPI DllUnregisterServer(void)
  89. {
  90.     return _Module.UnregisterServer(TRUE);
  91. }
  92.  
  93.  
  94.