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

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

Generated on Sat May 26 2012 04:19:49 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.