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.

88 lines
2.4 KiB

  1. // ndmedia.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f ndmediaps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include <initguid.h>
  7. #include "wiadef.h" // this is done on purpose to get the GUID for the commands
  8. #include "wiascr_i.c"
  9. #include "wiaproto.h"
  10. CComModule _Module;
  11. BEGIN_OBJECT_MAP(ObjectMap)
  12. OBJECT_ENTRY(CLSID_Wia, CWia)
  13. OBJECT_ENTRY(CLSID_SafeWia, CSafeWia)
  14. OBJECT_ENTRY(CLSID_WiaProtocol, CWiaProtocol)
  15. END_OBJECT_MAP()
  16. /////////////////////////////////////////////////////////////////////////////
  17. // DLL Entry Point
  18. extern "C"
  19. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  20. {
  21. if (dwReason == DLL_PROCESS_ATTACH)
  22. {
  23. RESTOREDEFAULTDEBUGSTATE
  24. _Module.Init(ObjectMap, hInstance, &LIBID_WIALib);
  25. DisableThreadLibraryCalls(hInstance);
  26. if ( !CWiaCacheManager::Init() )
  27. {
  28. TraceTag((tagError, "An error occured while initializing our cache" ));
  29. return FALSE;
  30. }
  31. }
  32. else if (dwReason == DLL_PROCESS_DETACH)
  33. {
  34. if ( !CWiaCacheManager::Uninit() )
  35. {
  36. TraceTag((tagError, "An error occured while Uninitializing our cache" ));
  37. }
  38. DUMPTRACKEDOBJECTS
  39. _Module.Term();
  40. }
  41. return TRUE; // ok
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. // Used to determine whether the DLL can be unloaded by OLE
  45. STDAPI DllCanUnloadNow(void)
  46. {
  47. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  48. }
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Returns a class factory to create an object of the requested type
  51. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  52. {
  53. return _Module.GetClassObject(rclsid, riid, ppv);
  54. }
  55. /////////////////////////////////////////////////////////////////////////////
  56. // DllRegisterServer - Adds entries to the system registry
  57. STDAPI DllRegisterServer(void)
  58. {
  59. // registers object, typelib and all interfaces in typelib
  60. return _Module.RegisterServer(TRUE);
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. // DllUnregisterServer - Removes entries from the system registry
  64. STDAPI DllUnregisterServer(void)
  65. {
  66. return _Module.UnregisterServer(TRUE);
  67. }