ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

msvidctl.cpp
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:       See COPYING in the top level directory
00003  * PROJECT:         ReactOS DVB
00004  * FILE:            dll/directx/msvidctl/msvidctl.cpp
00005  * PURPOSE:         ReactOS DVB Initialization
00006  *
00007  * PROGRAMMERS:     Johannes Anderwald (janderwald@reactos.org)
00008  */
00009 
00010 #include "precomp.h"
00011 
00012 static INTERFACE_TABLE InterfaceTable[] =
00013 {
00014     {&CLSID_SystemTuningSpaces, CTuningSpaceContainer_fnConstructor},
00015     {NULL, NULL}
00016 };
00017 
00018 extern "C"
00019 BOOL
00020 WINAPI
00021 DllMain(
00022     HINSTANCE hInstDLL,
00023     DWORD fdwReason,
00024     LPVOID lpvReserved)
00025 {
00026     switch (fdwReason)
00027     {
00028         case DLL_PROCESS_ATTACH:
00029             CoInitialize(NULL);
00030 
00031 #ifdef MSDVBNP_TRACE
00032             OutputDebugStringW(L"MSVIDCTL::DllMain()\n");
00033 #endif
00034 
00035             DisableThreadLibraryCalls(hInstDLL);
00036             break;
00037     default:
00038         break;
00039     }
00040 
00041     return TRUE;
00042 }
00043 
00044 
00045 extern "C"
00046 KSDDKAPI
00047 HRESULT
00048 WINAPI
00049 DllUnregisterServer(void)
00050 {
00051     ULONG Index = 0;
00052     LPOLESTR pStr;
00053     HRESULT hr = S_OK;
00054     HKEY hClass;
00055 
00056     if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_SET_VALUE, &hClass) != ERROR_SUCCESS)
00057         return E_FAIL;
00058 
00059     do
00060     {
00061         hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
00062         if (FAILED(hr))
00063             break;
00064 
00065         RegDeleteKeyW(hClass, pStr);
00066         CoTaskMemFree(pStr);
00067         Index++;
00068     }while(InterfaceTable[Index].lpfnCI != 0);
00069 
00070     RegCloseKey(hClass);
00071     return hr;
00072 }
00073 
00074 extern "C"
00075 KSDDKAPI
00076 HRESULT
00077 WINAPI
00078 DllRegisterServer(void)
00079 {
00080     ULONG Index = 0;
00081     LPOLESTR pStr;
00082     HRESULT hr = S_OK;
00083     HKEY hClass, hKey, hSubKey;
00084     static LPCWSTR ModuleName = L"msvidctl.ax";
00085     static LPCWSTR ThreadingModel = L"Both";
00086 
00087     if (RegOpenKeyExW(HKEY_CLASSES_ROOT, L"CLSID", 0, KEY_WRITE, &hClass) != ERROR_SUCCESS)
00088         return E_FAIL;
00089 
00090     do
00091     {
00092         hr = StringFromCLSID(*InterfaceTable[Index].riid, &pStr);
00093         if (FAILED(hr))
00094             break;
00095 
00096         if (RegCreateKeyExW(hClass, pStr, 0, 0, 0, KEY_WRITE, NULL, &hKey, 0) == ERROR_SUCCESS)
00097         {
00098             if (RegCreateKeyExW(hKey, L"InprocServer32", 0, 0, 0, KEY_WRITE, NULL, &hSubKey, 0) == ERROR_SUCCESS)
00099             {
00100                 RegSetValueExW(hSubKey, 0, 0, REG_SZ, (const BYTE*)ModuleName, (wcslen(ModuleName) + 1) * sizeof(WCHAR));
00101                 RegSetValueExW(hSubKey, L"ThreadingModel", 0, REG_SZ, (const BYTE*)ThreadingModel, (wcslen(ThreadingModel) + 1) * sizeof(WCHAR));
00102                 RegCloseKey(hSubKey);
00103             }
00104             RegCloseKey(hKey);
00105         }
00106 
00107         CoTaskMemFree(pStr);
00108         Index++;
00109     }while(InterfaceTable[Index].lpfnCI != 0);
00110 
00111     RegCloseKey(hClass);
00112     return hr;
00113 }
00114 
00115 KSDDKAPI
00116 HRESULT
00117 WINAPI
00118 DllGetClassObject(
00119     REFCLSID rclsid,
00120     REFIID riid,
00121     LPVOID *ppv)
00122 {
00123     UINT i;
00124     HRESULT hres = E_OUTOFMEMORY;
00125     IClassFactory * pcf = NULL; 
00126 
00127     if (!ppv)
00128         return E_INVALIDARG;
00129 
00130     *ppv = NULL;
00131 
00132     for (i = 0; InterfaceTable[i].riid; i++) 
00133     {
00134         if (IsEqualIID(*InterfaceTable[i].riid, rclsid)) 
00135         {
00136             pcf = CClassFactory_fnConstructor(InterfaceTable[i].lpfnCI, NULL, NULL);
00137             break;
00138         }
00139     }
00140 
00141     if (!pcf) 
00142     {
00143         return CLASS_E_CLASSNOTAVAILABLE;
00144     }
00145 
00146     hres = pcf->QueryInterface(riid, ppv);
00147     pcf->Release();
00148 
00149     return hres;
00150 }
00151 
00152 KSDDKAPI
00153 HRESULT
00154 WINAPI
00155 DllCanUnloadNow(void)
00156 {
00157     return S_OK;
00158 }

Generated on Sat May 26 2012 04:20:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.