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

  1. //------------------------------------------------------------------------------
  2. // File: DMOSample.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. #include "stdafx.h"
  11.  
  12. #define FIX_LOCK_NAME
  13. #include <dmo.h>
  14.  
  15. #include <dmoimpl.h>
  16. #include "resource.h"
  17. #include <initguid.h>
  18. #include <limits.h>
  19. #include "state.h"
  20. #include "Sample.h"
  21.  
  22.  
  23. CComModule _Module;
  24.  
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(CLSID_Sample, CSample)
  27. END_OBJECT_MAP()
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // DLL Entry Point
  31.  
  32. extern "C"
  33. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  34. {
  35.     if (dwReason == DLL_PROCESS_ATTACH)
  36.     {
  37.         _Module.Init(ObjectMap, hInstance);
  38.         DisableThreadLibraryCalls(hInstance);
  39.     }
  40.     else if (dwReason == DLL_PROCESS_DETACH)
  41.         _Module.Term();
  42.     return TRUE;    // ok
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // Used to determine whether the DLL can be unloaded by OLE
  47.  
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // Returns a class factory to create an object of the requested type
  55.  
  56. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  57. {
  58.     return _Module.GetClassObject(rclsid, riid, ppv);
  59. }
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // DllRegisterServer - Adds entries to the system registry
  63.  
  64. STDAPI DllRegisterServer(void)
  65. {
  66.     // Register ourselves as a DMO with no types
  67.     // RGS file also registers with a merit of 0 so DShow won't try to use us
  68.     DMORegister(L"DMO Sample", 
  69.                 CLSID_Sample, 
  70.                 DMOCATEGORY_VIDEO_DECODER,
  71.                 0,
  72.                 0,
  73.                 NULL,
  74.                 0,
  75.                 NULL);
  76.  
  77.     // registers object
  78.     return _Module.RegisterServer();
  79. }
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // DllUnregisterServer - Removes entries from the system registry
  83.  
  84. STDAPI DllUnregisterServer(void)
  85. {
  86.     DMOUnregister(CLSID_Sample, DMOCATEGORY_VIDEO_DECODER);
  87.     return _Module.UnregisterServer();
  88. }
  89.  
  90.  
  91.