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.

127 lines
3.4 KiB

  1. // camocx.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To merge the proxy/stub code into the object DLL, add the file
  4. // dlldatax.c to the project. Make sure precompiled headers
  5. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  6. // defines for the project.
  7. //
  8. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  9. // need to remove the following define from dlldatax.c
  10. // #define _WIN32_WINNT 0x0400
  11. //
  12. // Further, if you are running MIDL without /Oicf switch, you also
  13. // need to remove the following define from dlldatax.c.
  14. // #define USE_STUBLESS_PROXY
  15. //
  16. // Modify the custom build rule for camocx.idl by adding the following
  17. // files to the Outputs.
  18. // camocx_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f camocxps.mk in the project directory.
  22. #include "precomp.h"
  23. #pragma hdrstop
  24. #include "wiaview_i.c"
  25. #ifdef _MERGE_PROXYSTUB
  26. extern "C" HINSTANCE hProxyDll;
  27. #endif
  28. CComModule _Module;
  29. HINSTANCE g_hInstance;
  30. BEGIN_OBJECT_MAP(ObjectMap)
  31. OBJECT_ENTRY(CLSID_VideoPreview, CVideoPreview)
  32. END_OBJECT_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // DLL Entry Point
  35. extern "C"
  36. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  37. {
  38. lpReserved;
  39. #ifdef _MERGE_PROXYSTUB
  40. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  41. return FALSE;
  42. #endif
  43. if (dwReason == DLL_PROCESS_ATTACH)
  44. {
  45. SHFusionInitializeFromModuleID( hInstance, 123 );
  46. _Module.Init(ObjectMap, hInstance /* &LIBID_WIAVIEWLib*/);
  47. WIA_DEBUG_CREATE( hInstance );
  48. DisableThreadLibraryCalls(hInstance);
  49. g_hInstance = hInstance;
  50. }
  51. else if (dwReason == DLL_PROCESS_DETACH)
  52. {
  53. SHFusionUninitialize();
  54. WIA_DEBUG_DESTROY();
  55. _Module.Term();
  56. }
  57. return TRUE; // ok
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Used to determine whether the DLL can be unloaded by OLE
  61. STDAPI DllCanUnloadNow(void)
  62. {
  63. HRESULT hr;
  64. #ifdef _MERGE_PROXYSTUB
  65. if (PrxDllCanUnloadNow() != S_OK)
  66. return S_FALSE;
  67. #endif
  68. hr = (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  69. return hr;
  70. }
  71. /////////////////////////////////////////////////////////////////////////////
  72. // Returns a class factory to create an object of the requested type
  73. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  74. {
  75. #ifdef _MERGE_PROXYSTUB
  76. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  77. return S_OK;
  78. #endif
  79. return _Module.GetClassObject(rclsid, riid, ppv);
  80. }
  81. /////////////////////////////////////////////////////////////////////////////
  82. // DllRegisterServer - Adds entries to the system registry
  83. STDAPI DllRegisterServer(void)
  84. {
  85. #ifdef _MERGE_PROXYSTUB
  86. HRESULT hRes = PrxDllRegisterServer();
  87. if (FAILED(hRes))
  88. return hRes;
  89. #endif
  90. // registers object, typelib and all interfaces in typelib
  91. return _Module.RegisterServer(TRUE);
  92. }
  93. /////////////////////////////////////////////////////////////////////////////
  94. // DllUnregisterServer - Removes entries from the system registry
  95. STDAPI DllUnregisterServer(void)
  96. {
  97. #ifdef _MERGE_PROXYSTUB
  98. PrxDllUnregisterServer();
  99. #endif
  100. return _Module.UnregisterServer();
  101. }