2 * Regster/Unregister servers. (for internal use)
4 * hidenori@a2.ctktv.ne.jp
17 #include "debugtools.h"
18 DEFAULT_DEBUG_CHANNEL(quartz);
23 #define NUMELEMS(elem) (sizeof(elem)/sizeof((elem)[0]))
26 const WCHAR QUARTZ_wszREG_SZ[] =
27 {'R','E','G','_','S','Z',0};
28 const WCHAR QUARTZ_wszInprocServer32[] =
29 {'I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
30 const WCHAR QUARTZ_wszThreadingModel[] =
31 {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0};
32 const WCHAR QUARTZ_wszBoth[] =
34 const WCHAR QUARTZ_wszCLSID[] =
35 {'C','L','S','I','D',0};
36 const WCHAR QUARTZ_wszFilterData[] =
37 {'F','i','l','t','e','r',' ','D','a','t','a',0};
38 const WCHAR QUARTZ_wszFriendlyName[] =
39 {'F','r','i','e','n','d','l','y','N','a','m','e',0};
40 const WCHAR QUARTZ_wszInstance[] =
41 {'I','n','s','t','a','n','c','e',0};
42 const WCHAR QUARTZ_wszMerit[] =
43 {'M','e','r','i','t',0};
46 void QUARTZ_CatPathSepW( WCHAR* pBuf )
48 int len = lstrlenW(pBuf);
54 void QUARTZ_GUIDtoString( WCHAR* pBuf, const GUID* pguid )
56 /* W"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}" */
57 static const WCHAR wszFmt[] =
58 {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X',
59 '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%',
60 '0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',
61 '%','0','2','X','}',0};
63 wsprintfW( pBuf, wszFmt,
64 pguid->Data1, pguid->Data2, pguid->Data3,
65 pguid->Data4[0], pguid->Data4[1],
66 pguid->Data4[2], pguid->Data4[3],
67 pguid->Data4[4], pguid->Data4[5],
68 pguid->Data4[6], pguid->Data4[7] );
72 LONG QUARTZ_RegOpenKeyW(
73 HKEY hkRoot, LPCWSTR lpszPath,
74 REGSAM rsAccess, HKEY* phKey,
78 WCHAR wszREG_SZ[ NUMELEMS(QUARTZ_wszREG_SZ) ];
80 memcpy(wszREG_SZ,QUARTZ_wszREG_SZ,sizeof(QUARTZ_wszREG_SZ) );
83 return RegCreateKeyExW(
84 hkRoot, lpszPath, 0, wszREG_SZ,
85 REG_OPTION_NON_VOLATILE, rsAccess, NULL, phKey, &dwDisp );
88 hkRoot, lpszPath, 0, rsAccess, phKey );
92 LONG QUARTZ_RegSetValueString(
93 HKEY hKey, LPCWSTR lpszName, LPCWSTR lpValue )
95 return RegSetValueExW(
96 hKey, lpszName, 0, REG_SZ,
98 sizeof(lpValue[0]) * (lstrlenW(lpValue)+1) );
102 LONG QUARTZ_RegSetValueDWord(
103 HKEY hKey, LPCWSTR lpszName, DWORD dwValue )
105 return RegSetValueExW(
106 hKey, lpszName, 0, REG_DWORD,
107 (const BYTE*)(&dwValue), sizeof(DWORD) );
111 LONG QUARTZ_RegSetValueBinary(
112 HKEY hKey, LPCWSTR lpszName,
113 const BYTE* pData, int iLenOfData )
115 return RegSetValueExW(
116 hKey, lpszName, 0, REG_BINARY, pData, iLenOfData );
119 HRESULT QUARTZ_CreateCLSIDPath(
120 WCHAR* pwszBuf, DWORD dwBufLen,
122 LPCWSTR lpszPathFromCLSID )
126 lstrcpyW( pwszBuf, QUARTZ_wszCLSID );
127 QUARTZ_CatPathSepW( pwszBuf+5 );
128 QUARTZ_GUIDtoString( pwszBuf+6, pclsid );
129 if ( lpszPathFromCLSID != NULL )
131 avail = (int)dwBufLen - lstrlenW(pwszBuf) - 8;
132 if ( avail <= lstrlenW(lpszPathFromCLSID) )
134 QUARTZ_CatPathSepW( pwszBuf );
135 lstrcatW( pwszBuf, lpszPathFromCLSID );
141 HRESULT QUARTZ_OpenCLSIDKey(
142 HKEY* phKey, /* [OUT] hKey */
143 REGSAM rsAccess, /* [IN] access */
144 BOOL fCreate, /* TRUE = RegCreateKey, FALSE = RegOpenKey */
145 const CLSID* pclsid, /* CLSID */
146 LPCWSTR lpszPathFromCLSID ) /* related path from CLSID */
152 hr = QUARTZ_CreateCLSIDPath(
153 szKey, NUMELEMS(szKey),
154 pclsid, lpszPathFromCLSID );
158 lr = QUARTZ_RegOpenKeyW(
159 HKEY_CLASSES_ROOT, szKey, rsAccess, phKey, fCreate );
160 if ( lr != ERROR_SUCCESS )
168 HRESULT QUARTZ_RegisterAMovieDLLServer(
169 const CLSID* pclsid, /* [IN] CLSID */
170 LPCWSTR lpFriendlyName, /* [IN] Friendly name */
171 LPCWSTR lpNameOfDLL, /* [IN] name of the registered DLL */
172 BOOL fRegister ) /* [IN] TRUE = register, FALSE = unregister */
179 hr = QUARTZ_OpenCLSIDKey(
180 &hKey, KEY_ALL_ACCESS, TRUE,
185 if ( lpFriendlyName != NULL && QUARTZ_RegSetValueString(
186 hKey, NULL, lpFriendlyName ) != ERROR_SUCCESS )
193 hr = QUARTZ_OpenCLSIDKey(
194 &hKey, KEY_ALL_ACCESS, TRUE,
195 pclsid, QUARTZ_wszInprocServer32 );
199 if ( QUARTZ_RegSetValueString(
200 hKey, NULL, lpNameOfDLL ) != ERROR_SUCCESS )
202 if ( QUARTZ_RegSetValueString(
203 hKey, QUARTZ_wszThreadingModel,
204 QUARTZ_wszBoth ) != ERROR_SUCCESS )
213 hr = QUARTZ_OpenCLSIDKey(
214 &hKey, KEY_ALL_ACCESS, FALSE,
219 RegDeleteValueW( hKey, NULL );
220 RegDeleteValueW( hKey, QUARTZ_wszThreadingModel );
226 /* I think key should be deleted only if no subkey exists. */
227 FIXME( "unregister %s - key should be removed!\n",
228 debugstr_guid(pclsid) );
235 HRESULT QUARTZ_RegisterCategory(
236 const CLSID* pguidFilterCategory, /* [IN] Category */
237 LPCWSTR lpFriendlyName, /* [IN] friendly name */
238 DWORD dwMerit, /* [IN] merit */
239 BOOL fRegister ) /* [IN] TRUE = register, FALSE = unregister */
243 WCHAR szFilterPath[ 256 ];
244 WCHAR szCLSID[ 256 ];
246 QUARTZ_GUIDtoString( szCLSID, pguidFilterCategory );
247 lstrcpyW( szFilterPath, QUARTZ_wszInstance );
248 QUARTZ_CatPathSepW( szFilterPath );
249 lstrcatW( szFilterPath, szCLSID );
253 hr = QUARTZ_OpenCLSIDKey(
254 &hKey, KEY_ALL_ACCESS, TRUE,
255 &CLSID_ActiveMovieCategories, szFilterPath );
259 if ( QUARTZ_RegSetValueString(
260 hKey, QUARTZ_wszCLSID, szCLSID ) != ERROR_SUCCESS )
262 if ( lpFriendlyName != NULL && QUARTZ_RegSetValueString(
263 hKey, QUARTZ_wszFriendlyName,
264 lpFriendlyName ) != ERROR_SUCCESS )
267 QUARTZ_RegSetValueDWord(
268 hKey, QUARTZ_wszMerit, dwMerit ) != ERROR_SUCCESS )
277 hr = QUARTZ_OpenCLSIDKey(
278 &hKey, KEY_ALL_ACCESS, FALSE,
279 &CLSID_ActiveMovieCategories, szFilterPath );
283 RegDeleteValueW( hKey, QUARTZ_wszCLSID );
284 RegDeleteValueW( hKey, QUARTZ_wszFriendlyName );
285 RegDeleteValueW( hKey, QUARTZ_wszMerit );
291 /* I think key should be deleted only if no subkey exists. */
292 FIXME( "unregister category %s - key should be removed!\n",
293 debugstr_guid(pguidFilterCategory) );
300 HRESULT QUARTZ_RegisterAMovieFilter(
301 const CLSID* pguidFilterCategory, /* [IN] Category */
302 const CLSID* pclsid, /* [IN] CLSID of this filter */
303 const BYTE* pbFilterData, /* [IN] filter data(no spec) */
304 DWORD cbFilterData, /* [IN] size of the filter data */
305 LPCWSTR lpFriendlyName, /* [IN] friendly name */
306 LPCWSTR lpInstance, /* [IN] instance */
307 BOOL fRegister ) /* [IN] TRUE = register, FALSE = unregister */
311 WCHAR szFilterPath[ 256 ];
312 WCHAR szCLSID[ 256 ];
314 QUARTZ_GUIDtoString( szCLSID, pclsid );
315 lstrcpyW( szFilterPath, QUARTZ_wszInstance );
316 QUARTZ_CatPathSepW( szFilterPath );
317 lstrcatW( szFilterPath, ( lpInstance != NULL ) ? lpInstance : szCLSID );
321 hr = QUARTZ_OpenCLSIDKey(
322 &hKey, KEY_ALL_ACCESS, TRUE,
323 pguidFilterCategory, szFilterPath );
327 if ( QUARTZ_RegSetValueString(
328 hKey, QUARTZ_wszCLSID, szCLSID ) != ERROR_SUCCESS )
330 if ( pbFilterData != NULL && cbFilterData > 0 &&
331 QUARTZ_RegSetValueBinary(
332 hKey, QUARTZ_wszFilterData,
333 pbFilterData, cbFilterData ) != ERROR_SUCCESS )
335 if ( lpFriendlyName != NULL && QUARTZ_RegSetValueString(
336 hKey, QUARTZ_wszFriendlyName,
337 lpFriendlyName ) != ERROR_SUCCESS )
346 hr = QUARTZ_OpenCLSIDKey(
347 &hKey, KEY_ALL_ACCESS, FALSE,
348 pguidFilterCategory, szFilterPath );
352 RegDeleteValueW( hKey, QUARTZ_wszCLSID );
353 RegDeleteValueW( hKey, QUARTZ_wszFilterData );
354 RegDeleteValueW( hKey, QUARTZ_wszFriendlyName );
360 /* I think key should be deleted only if no subkey exists. */
361 FIXME( "unregister category %s filter %s - key should be removed!\n",
362 debugstr_guid(pguidFilterCategory),
363 debugstr_guid(pclsid) );