| 1 | /*
|
|---|
| 2 | * Implementation of ICreateDevEnum for CLSID_SystemDeviceEnum.
|
|---|
| 3 | *
|
|---|
| 4 | * FIXME - stub.
|
|---|
| 5 | *
|
|---|
| 6 | * hidenori@a2.ctktv.ne.jp
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | #include "config.h"
|
|---|
| 10 |
|
|---|
| 11 | #include "windef.h"
|
|---|
| 12 | #include "winbase.h"
|
|---|
| 13 | #include "wingdi.h"
|
|---|
| 14 | #include "winuser.h"
|
|---|
| 15 | #include "winreg.h"
|
|---|
| 16 | #include "winerror.h"
|
|---|
| 17 | #include "wine/obj_base.h"
|
|---|
| 18 | #include "objidl.h"
|
|---|
| 19 | #include "oleidl.h"
|
|---|
| 20 | #include "ocidl.h"
|
|---|
| 21 | #include "strmif.h"
|
|---|
| 22 | #include "control.h"
|
|---|
| 23 | #include "uuids.h"
|
|---|
| 24 | #include "wine/unicode.h"
|
|---|
| 25 |
|
|---|
| 26 | #include "debugtools.h"
|
|---|
| 27 | DEFAULT_DEBUG_CHANNEL(quartz);
|
|---|
| 28 |
|
|---|
| 29 | #include "quartz_private.h"
|
|---|
| 30 | #include "devenum.h"
|
|---|
| 31 | #include "regsvr.h"
|
|---|
| 32 | #include "enumunk.h"
|
|---|
| 33 | #include "complist.h"
|
|---|
| 34 | #include "devmon.h"
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | static HRESULT WINAPI
|
|---|
| 38 | ICreateDevEnum_fnQueryInterface(ICreateDevEnum* iface,REFIID riid,void** ppobj)
|
|---|
| 39 | {
|
|---|
| 40 | CSysDevEnum_THIS(iface,createdevenum);
|
|---|
| 41 |
|
|---|
| 42 | TRACE("(%p)->()\n",This);
|
|---|
| 43 |
|
|---|
| 44 | return IUnknown_QueryInterface(This->unk.punkControl,riid,ppobj);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | static ULONG WINAPI
|
|---|
| 48 | ICreateDevEnum_fnAddRef(ICreateDevEnum* iface)
|
|---|
| 49 | {
|
|---|
| 50 | CSysDevEnum_THIS(iface,createdevenum);
|
|---|
| 51 |
|
|---|
| 52 | TRACE("(%p)->()\n",This);
|
|---|
| 53 |
|
|---|
| 54 | return IUnknown_AddRef(This->unk.punkControl);
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | static ULONG WINAPI
|
|---|
| 58 | ICreateDevEnum_fnRelease(ICreateDevEnum* iface)
|
|---|
| 59 | {
|
|---|
| 60 | CSysDevEnum_THIS(iface,createdevenum);
|
|---|
| 61 |
|
|---|
| 62 | TRACE("(%p)->()\n",This);
|
|---|
| 63 |
|
|---|
| 64 | return IUnknown_Release(This->unk.punkControl);
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | static HRESULT WINAPI
|
|---|
| 68 | ICreateDevEnum_fnCreateClassEnumerator(ICreateDevEnum* iface,REFCLSID rclsidDeviceClass,IEnumMoniker** ppobj, DWORD dwFlags)
|
|---|
| 69 | {
|
|---|
| 70 | CSysDevEnum_THIS(iface,createdevenum);
|
|---|
| 71 | HRESULT hr;
|
|---|
| 72 | HKEY hKey;
|
|---|
| 73 | QUARTZ_CompList* pMonList;
|
|---|
| 74 | IMoniker* pMon;
|
|---|
| 75 | DWORD dwIndex;
|
|---|
| 76 | LONG lr;
|
|---|
| 77 | WCHAR wszPath[ 1024 ];
|
|---|
| 78 | DWORD dwLen;
|
|---|
| 79 | DWORD dwNameMax;
|
|---|
| 80 | DWORD cbName;
|
|---|
| 81 | FILETIME ftLastWrite;
|
|---|
| 82 |
|
|---|
| 83 | TRACE("(%p)->(%s,%p,%08lx)\n",This,
|
|---|
| 84 | debugstr_guid(rclsidDeviceClass),ppobj,dwFlags);
|
|---|
| 85 | if ( dwFlags != 0 )
|
|---|
| 86 | {
|
|---|
| 87 | FIXME("unknown flags %08lx\n",dwFlags);
|
|---|
| 88 | return E_NOTIMPL;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | if ( ppobj == NULL )
|
|---|
| 92 | return E_POINTER;
|
|---|
| 93 | *ppobj = NULL;
|
|---|
| 94 |
|
|---|
| 95 | hr = QUARTZ_CreateCLSIDPath(
|
|---|
| 96 | wszPath, sizeof(wszPath)/sizeof(wszPath[0]),
|
|---|
| 97 | rclsidDeviceClass, QUARTZ_wszInstance );
|
|---|
| 98 | if ( FAILED(hr) )
|
|---|
| 99 | return hr;
|
|---|
| 100 |
|
|---|
| 101 | if ( RegOpenKeyExW( HKEY_CLASSES_ROOT, wszPath,
|
|---|
| 102 | 0, KEY_READ, &hKey ) != ERROR_SUCCESS )
|
|---|
| 103 | return E_FAIL;
|
|---|
| 104 |
|
|---|
| 105 | dwLen = strlenW(wszPath);
|
|---|
| 106 | wszPath[dwLen++] = '\\'; wszPath[dwLen] = 0;
|
|---|
| 107 | dwNameMax = sizeof(wszPath)/sizeof(wszPath[0]) - dwLen - 8;
|
|---|
| 108 |
|
|---|
| 109 | pMonList = QUARTZ_CompList_Alloc();
|
|---|
| 110 | if ( pMonList == NULL )
|
|---|
| 111 | {
|
|---|
| 112 | hr = E_OUTOFMEMORY;
|
|---|
| 113 | goto err;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | /* enumerate all subkeys. */
|
|---|
| 117 | dwIndex = 0;
|
|---|
| 118 | while ( 1 )
|
|---|
| 119 | {
|
|---|
| 120 | cbName = dwNameMax;
|
|---|
| 121 | lr = RegEnumKeyExW(
|
|---|
| 122 | hKey, dwIndex, &wszPath[dwLen], &cbName,
|
|---|
| 123 | NULL, NULL, NULL, &ftLastWrite );
|
|---|
| 124 | if ( lr == ERROR_NO_MORE_ITEMS )
|
|---|
| 125 | break;
|
|---|
| 126 | if ( lr != ERROR_SUCCESS )
|
|---|
| 127 | {
|
|---|
| 128 | hr = E_FAIL;
|
|---|
| 129 | goto err;
|
|---|
| 130 | }
|
|---|
| 131 |
|
|---|
| 132 | hr = QUARTZ_CreateDeviceMoniker(
|
|---|
| 133 | HKEY_CLASSES_ROOT, wszPath, &pMon );
|
|---|
| 134 | if ( FAILED(hr) )
|
|---|
| 135 | goto err;
|
|---|
| 136 |
|
|---|
| 137 | hr = QUARTZ_CompList_AddComp(
|
|---|
| 138 | pMonList, (IUnknown*)pMon, NULL, 0 );
|
|---|
| 139 | IMoniker_Release( pMon );
|
|---|
| 140 |
|
|---|
| 141 | if ( FAILED(hr) )
|
|---|
| 142 | goto err;
|
|---|
| 143 |
|
|---|
| 144 | dwIndex ++;
|
|---|
| 145 | }
|
|---|
| 146 |
|
|---|
| 147 | /* create an enumerator. */
|
|---|
| 148 | hr = QUARTZ_CreateEnumUnknown(
|
|---|
| 149 | &IID_IEnumMoniker, (void**)ppobj, pMonList );
|
|---|
| 150 | if ( FAILED(hr) )
|
|---|
| 151 | goto err;
|
|---|
| 152 |
|
|---|
| 153 | hr = S_OK;
|
|---|
| 154 | err:
|
|---|
| 155 | if ( pMonList != NULL )
|
|---|
| 156 | QUARTZ_CompList_Free( pMonList );
|
|---|
| 157 | RegCloseKey( hKey );
|
|---|
| 158 |
|
|---|
| 159 | return hr;
|
|---|
| 160 | }
|
|---|
| 161 |
|
|---|
| 162 | static ICOM_VTABLE(ICreateDevEnum) icreatedevenum =
|
|---|
| 163 | {
|
|---|
| 164 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|---|
| 165 | /* IUnknown fields */
|
|---|
| 166 | ICreateDevEnum_fnQueryInterface,
|
|---|
| 167 | ICreateDevEnum_fnAddRef,
|
|---|
| 168 | ICreateDevEnum_fnRelease,
|
|---|
| 169 | /* ICreateDevEnum fields */
|
|---|
| 170 | ICreateDevEnum_fnCreateClassEnumerator,
|
|---|
| 171 | };
|
|---|
| 172 |
|
|---|
| 173 | HRESULT CSysDevEnum_InitICreateDevEnum( CSysDevEnum* psde )
|
|---|
| 174 | {
|
|---|
| 175 | TRACE("(%p)\n",psde);
|
|---|
| 176 | ICOM_VTBL(&psde->createdevenum) = &icreatedevenum;
|
|---|
| 177 |
|
|---|
| 178 | return NOERROR;
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | void CSysDevEnum_UninitICreateDevEnum( CSysDevEnum* psde )
|
|---|
| 182 | {
|
|---|
| 183 | TRACE("(%p)\n",psde);
|
|---|
| 184 | }
|
|---|