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.

59 lines
2.3 KiB

  1. //==========================================================================;
  2. //
  3. // Copyright (c) Microsoft Corporation 1999-2000.
  4. //
  5. //--------------------------------------------------------------------------;
  6. //
  7. // factoryhelp.h - helper class for creating vidctl instances from a variety of factories including element
  8. // behavior factories and pluggable protocols
  9. #include "atlbase.h"
  10. typedef CComQIPtr<ICreatePropBagOnRegKey> PQCreatePropBagOnRegKey;
  11. typedef CComQIPtr<IWebBrowserApp> PQWebBrowserApp;
  12. typedef CComQIPtr<IWebBrowser2> PQWebBrowser2;
  13. #define RBFACTORY_DEFAULT_KEY OLESTR("Software\\Microsoft\\MSVidCtl")
  14. #define PROPNAME_DEFAULT_TR OLESTR("DefaultTuneRequest")
  15. LPCOLESTR __declspec(selectany) BIND_TO_OBJ_VAL = OLESTR("TRUE");
  16. LPOLESTR __declspec(selectany) KEY_CLSID_VidCtl = OLESTR("B0EDF163-910A-11D2-B632-00C04F79498E");
  17. LPCOLESTR __declspec(selectany) TVPROT_SCHEME_NAME = OLESTR("tv");
  18. LPCOLESTR __declspec(selectany) DVDPROT_SCHEME_NAME = OLESTR("dvd");
  19. class CFactoryHelper {
  20. public:
  21. static CComVariant GetDefaultTR() {
  22. PQPropertyBag pBag;
  23. PQCreatePropBagOnRegKey pCreateBag(CLSID_CreatePropBagOnRegKey, NULL, CLSCTX_INPROC_SERVER);
  24. if (!pCreateBag) {
  25. TRACELM(TRACE_ERROR, "can't create prop bag");
  26. return CComVariant();
  27. }
  28. HRESULT hr = pCreateBag->Create(HKEY_CURRENT_USER, RBFACTORY_DEFAULT_KEY, 0, KEY_READ, IID_IPropertyBag, reinterpret_cast<LPVOID *>(&pBag));
  29. if (FAILED(hr)) {
  30. TRACELSM(TRACE_ERROR, (dbgDump << "No Default Tune Request Key Present. hr = " << hr), "");
  31. return CComVariant();
  32. }
  33. CComVariant pVar;
  34. hr = pBag->Read(PROPNAME_DEFAULT_TR, &pVar, NULL);
  35. if (FAILED(hr) || (pVar.vt != VT_UNKNOWN && pVar.vt != VT_DISPATCH)) {
  36. TRACELSM(TRACE_ERROR, (dbgDump << "No Default Tune Request Property Present. hr = " << hr), "");
  37. return CComVariant();
  38. }
  39. PQTuningSpace pts;
  40. PQTuneRequest ptr(pVar.vt == VT_UNKNOWN ? pVar.punkVal : pVar.pdispVal);
  41. if (!ptr) {
  42. TRACELSM(TRACE_ERROR, (dbgDump << PROPNAME_DEFAULT_TR << " not a tune request"), "");
  43. return CComVariant();
  44. }
  45. hr = ptr->get_TuningSpace(&pts);
  46. if (FAILED(hr) || !pts) {
  47. TRACELSM(TRACE_ERROR, (dbgDump << "Can't get ts from tr " << hr), "");
  48. return CComVariant();
  49. }
  50. return pVar;
  51. }
  52. };
  53. // end of file factoryhelp.h