Source code of Windows XP (NT5)
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.

164 lines
3.8 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998 - 2000
  4. *
  5. * TITLE: videousd.cpp
  6. *
  7. * VERSION: 1.1
  8. *
  9. * AUTHOR: WilliamH (created)
  10. * RickTu (modified for WIA)
  11. *
  12. * DATE: 9/7/99
  13. *
  14. * DESCRIPTION: This module implements wiavideo.dll
  15. *
  16. *****************************************************************************/
  17. #include <precomp.h>
  18. #pragma hdrstop
  19. #include <advpub.h>
  20. HINSTANCE g_hInstance;
  21. /*****************************************************************************
  22. DllMain
  23. <Notes>
  24. *****************************************************************************/
  25. BOOL
  26. DllMain(HINSTANCE hInstance,
  27. DWORD dwReason,
  28. LPVOID lpReserved)
  29. {
  30. switch (dwReason)
  31. {
  32. case DLL_PROCESS_ATTACH:
  33. //
  34. // Init the debug library
  35. //
  36. DBG_INIT(hInstance);
  37. //
  38. // We do not need thread attach/detach calls
  39. //
  40. DisableThreadLibraryCalls(hInstance);
  41. //
  42. // Record what instance we are
  43. //
  44. g_hInstance = hInstance;
  45. break;
  46. case DLL_PROCESS_DETACH:
  47. break;
  48. }
  49. return TRUE;
  50. }
  51. /*****************************************************************************
  52. DllCanUnloadNow
  53. Let the outside world know when they can unload this dll
  54. *****************************************************************************/
  55. STDAPI DllCanUnloadNow(void)
  56. {
  57. return CVideoUsdClassFactory::CanUnloadNow();
  58. }
  59. /*****************************************************************************
  60. DllGetClassObject
  61. This is what the outside world calls to get an object of ours
  62. instantiated.
  63. *****************************************************************************/
  64. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  65. {
  66. return CVideoUsdClassFactory::GetClassObject(rclsid, riid, ppv);
  67. }
  68. /*****************************************************************************
  69. Installs information in an .inf that is in our resource fork.
  70. <Notes>
  71. *****************************************************************************/
  72. HRESULT InstallInfFromResource(HINSTANCE hInstance,
  73. LPCSTR pszSectionName)
  74. {
  75. HRESULT hr;
  76. HINSTANCE hInstAdvPackDll = LoadLibrary(TEXT("ADVPACK.DLL"));
  77. if (hInstAdvPackDll)
  78. {
  79. REGINSTALL pfnRegInstall = reinterpret_cast<REGINSTALL>(GetProcAddress( hInstAdvPackDll, "RegInstall" ));
  80. if (pfnRegInstall)
  81. {
  82. #if defined(WINNT)
  83. STRENTRY astrEntry[] =
  84. {
  85. { "25", "%SystemRoot%" },
  86. { "11", "%SystemRoot%\\system32" }
  87. };
  88. STRTABLE strTable = { sizeof(astrEntry)/sizeof(astrEntry[0]), astrEntry };
  89. hr = pfnRegInstall(hInstance, pszSectionName, &strTable);
  90. #else
  91. hr = pfnRegInstall(hInstance, pszSectionName, NULL);
  92. #endif
  93. } else hr = HRESULT_FROM_WIN32(GetLastError());
  94. FreeLibrary(hInstAdvPackDll);
  95. } else hr = HRESULT_FROM_WIN32(GetLastError());
  96. return hr;
  97. }
  98. /*****************************************************************************
  99. DllRegisterServer
  100. Register the objects we provide.
  101. *****************************************************************************/
  102. STDAPI DllRegisterServer(void)
  103. {
  104. return InstallInfFromResource( g_hInstance, "RegDll" );
  105. }
  106. /*****************************************************************************
  107. DllUnregisterServer
  108. Unregister the objects we provide.
  109. *****************************************************************************/
  110. STDAPI DllUnregisterServer(void)
  111. {
  112. return InstallInfFromResource( g_hInstance, "UnregDll" );
  113. }