2 * Regster/Unregister servers. (for internal use)
4 * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
37 #define NUMELEMS(elem) (sizeof(elem)/sizeof((elem)[0]))
40 const WCHAR QUARTZ_wszREG_SZ
[7] =
41 {'R','E','G','_','S','Z',0};
42 const WCHAR QUARTZ_wszInprocServer32
[] =
43 {'I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
44 const WCHAR QUARTZ_wszThreadingModel
[] =
45 {'T','h','r','e','a','d','i','n','g','M','o','d','e','l',0};
46 const WCHAR QUARTZ_wszBoth
[] =
48 const WCHAR QUARTZ_wszCLSID
[] =
49 {'C','L','S','I','D',0};
50 const WCHAR QUARTZ_wszFilterData
[] =
51 {'F','i','l','t','e','r','D','a','t','a',0};
52 const WCHAR QUARTZ_wszFriendlyName
[] =
53 {'F','r','i','e','n','d','l','y','N','a','m','e',0};
54 const WCHAR QUARTZ_wszInstance
[] =
55 {'I','n','s','t','a','n','c','e',0};
56 const WCHAR QUARTZ_wszMerit
[] =
57 {'M','e','r','i','t',0};
58 const WCHAR QUARTZ_wszMediaType
[] =
59 {'M','e','d','i','a',' ','T','y','p','e',0};
60 const WCHAR QUARTZ_wszSubType
[] =
61 {'S','u','b','T','y','p','e',0};
62 const WCHAR QUARTZ_wszExtensions
[] =
63 {'E','x','t','e','n','s','i','o','n','s',0};
64 const WCHAR QUARTZ_wszSourceFilter
[] =
65 {'S','o','u','r','c','e',' ','F','i','l','t','e','r',0};
67 void QUARTZ_CatPathSepW( WCHAR
* pBuf
)
69 int len
= lstrlenW(pBuf
);
74 void QUARTZ_GUIDtoString( WCHAR
* pBuf
, const GUID
* pguid
)
76 /* W"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}" */
77 static const WCHAR wszFmt
[] =
78 {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X',
79 '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%',
80 '0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',
81 '%','0','2','X','}',0};
83 wsprintfW( pBuf
, wszFmt
,
84 pguid
->Data1
, pguid
->Data2
, pguid
->Data3
,
85 pguid
->Data4
[0], pguid
->Data4
[1],
86 pguid
->Data4
[2], pguid
->Data4
[3],
87 pguid
->Data4
[4], pguid
->Data4
[5],
88 pguid
->Data4
[6], pguid
->Data4
[7] );
92 LONG
QUARTZ_RegOpenKeyW(
93 HKEY hkRoot
, LPCWSTR lpszPath
,
94 REGSAM rsAccess
, HKEY
* phKey
,
98 WCHAR wszREG_SZ
[ NUMELEMS(QUARTZ_wszREG_SZ
) ];
100 memcpy(wszREG_SZ
,QUARTZ_wszREG_SZ
,sizeof(QUARTZ_wszREG_SZ
) );
103 return RegCreateKeyExW(
104 hkRoot
, lpszPath
, 0, wszREG_SZ
,
105 REG_OPTION_NON_VOLATILE
, rsAccess
, NULL
, phKey
, &dwDisp
);
107 return RegOpenKeyExW(
108 hkRoot
, lpszPath
, 0, rsAccess
, phKey
);
112 LONG
QUARTZ_RegSetValueString(
113 HKEY hKey
, LPCWSTR lpszName
, LPCWSTR lpValue
)
115 return RegSetValueExW(
116 hKey
, lpszName
, 0, REG_SZ
,
117 (const BYTE
*)lpValue
,
118 sizeof(lpValue
[0]) * (lstrlenW(lpValue
)+1) );
122 LONG
QUARTZ_RegSetValueDWord(
123 HKEY hKey
, LPCWSTR lpszName
, DWORD dwValue
)
125 return RegSetValueExW(
126 hKey
, lpszName
, 0, REG_DWORD
,
127 (const BYTE
*)(&dwValue
), sizeof(DWORD
) );
131 LONG
QUARTZ_RegSetValueBinary(
132 HKEY hKey
, LPCWSTR lpszName
,
133 const BYTE
* pData
, int iLenOfData
)
135 return RegSetValueExW(
136 hKey
, lpszName
, 0, REG_BINARY
, pData
, iLenOfData
);
139 HRESULT
QUARTZ_CreateCLSIDPath(
140 WCHAR
* pwszBuf
, DWORD dwBufLen
,
142 LPCWSTR lpszPathFromCLSID
)
146 lstrcpyW( pwszBuf
, QUARTZ_wszCLSID
);
147 QUARTZ_CatPathSepW( pwszBuf
+5 );
148 QUARTZ_GUIDtoString( pwszBuf
+6, pclsid
);
149 if ( lpszPathFromCLSID
!= NULL
)
151 avail
= (int)dwBufLen
- lstrlenW(pwszBuf
) - 8;
152 if ( avail
<= lstrlenW(lpszPathFromCLSID
) )
154 QUARTZ_CatPathSepW( pwszBuf
);
155 lstrcatW( pwszBuf
, lpszPathFromCLSID
);
161 HRESULT
QUARTZ_OpenCLSIDKey(
162 HKEY
* phKey
, /* [OUT] hKey */
163 REGSAM rsAccess
, /* [IN] access */
164 BOOL fCreate
, /* TRUE = RegCreateKey, FALSE = RegOpenKey */
165 const CLSID
* pclsid
, /* CLSID */
166 LPCWSTR lpszPathFromCLSID
) /* related path from CLSID */
172 hr
= QUARTZ_CreateCLSIDPath(
173 szKey
, NUMELEMS(szKey
),
174 pclsid
, lpszPathFromCLSID
);
178 lr
= QUARTZ_RegOpenKeyW(
179 HKEY_CLASSES_ROOT
, szKey
, rsAccess
, phKey
, fCreate
);
180 if ( lr
!= ERROR_SUCCESS
)
188 HRESULT
QUARTZ_RegisterAMovieDLLServer(
189 const CLSID
* pclsid
, /* [IN] CLSID */
190 LPCWSTR lpFriendlyName
, /* [IN] Friendly name */
191 LPCWSTR lpNameOfDLL
, /* [IN] name of the registered DLL */
192 BOOL fRegister
) /* [IN] TRUE = register, FALSE = unregister */
199 hr
= QUARTZ_OpenCLSIDKey(
200 &hKey
, KEY_ALL_ACCESS
, TRUE
,
205 if ( lpFriendlyName
!= NULL
&& QUARTZ_RegSetValueString(
206 hKey
, NULL
, lpFriendlyName
) != ERROR_SUCCESS
)
213 hr
= QUARTZ_OpenCLSIDKey(
214 &hKey
, KEY_ALL_ACCESS
, TRUE
,
215 pclsid
, QUARTZ_wszInprocServer32
);
219 if ( QUARTZ_RegSetValueString(
220 hKey
, NULL
, lpNameOfDLL
) != ERROR_SUCCESS
)
222 if ( QUARTZ_RegSetValueString(
223 hKey
, QUARTZ_wszThreadingModel
,
224 QUARTZ_wszBoth
) != ERROR_SUCCESS
)
233 hr
= QUARTZ_OpenCLSIDKey(
234 &hKey
, KEY_ALL_ACCESS
, FALSE
,
239 RegDeleteValueW( hKey
, NULL
);
240 RegDeleteValueW( hKey
, QUARTZ_wszThreadingModel
);
246 /* I think key should be deleted only if no subkey exists. */
247 FIXME( "unregister %s - key should be removed!\n",
248 debugstr_guid(pclsid
) );
255 HRESULT
QUARTZ_RegisterCategory(
256 const CLSID
* pguidFilterCategory
, /* [IN] Category */
257 LPCWSTR lpFriendlyName
, /* [IN] friendly name */
258 DWORD dwMerit
, /* [IN] merit */
259 BOOL fRegister
) /* [IN] TRUE = register, FALSE = unregister */
263 WCHAR szFilterPath
[ 256 ];
264 WCHAR szCLSID
[ 256 ];
266 QUARTZ_GUIDtoString( szCLSID
, pguidFilterCategory
);
267 lstrcpyW( szFilterPath
, QUARTZ_wszInstance
);
268 QUARTZ_CatPathSepW( szFilterPath
);
269 lstrcatW( szFilterPath
, szCLSID
);
273 hr
= QUARTZ_OpenCLSIDKey(
274 &hKey
, KEY_ALL_ACCESS
, TRUE
,
275 &CLSID_ActiveMovieCategories
, szFilterPath
);
279 if ( QUARTZ_RegSetValueString(
280 hKey
, QUARTZ_wszCLSID
, szCLSID
) != ERROR_SUCCESS
)
282 if ( lpFriendlyName
!= NULL
&& QUARTZ_RegSetValueString(
283 hKey
, QUARTZ_wszFriendlyName
,
284 lpFriendlyName
) != ERROR_SUCCESS
)
287 QUARTZ_RegSetValueDWord(
288 hKey
, QUARTZ_wszMerit
, dwMerit
) != ERROR_SUCCESS
)
297 hr
= QUARTZ_OpenCLSIDKey(
298 &hKey
, KEY_ALL_ACCESS
, FALSE
,
299 &CLSID_ActiveMovieCategories
, szFilterPath
);
303 RegDeleteValueW( hKey
, QUARTZ_wszCLSID
);
304 RegDeleteValueW( hKey
, QUARTZ_wszFriendlyName
);
305 RegDeleteValueW( hKey
, QUARTZ_wszMerit
);
311 /* I think key should be deleted only if no subkey exists. */
312 FIXME( "unregister category %s - key should be removed!\n",
313 debugstr_guid(pguidFilterCategory
) );
320 HRESULT
QUARTZ_RegisterAMovieFilter(
321 const CLSID
* pguidFilterCategory
, /* [IN] Category */
322 const CLSID
* pclsid
, /* [IN] CLSID of this filter */
323 const BYTE
* pbFilterData
, /* [IN] filter data(no spec) */
324 DWORD cbFilterData
, /* [IN] size of the filter data */
325 LPCWSTR lpFriendlyName
, /* [IN] friendly name */
326 LPCWSTR lpInstance
, /* [IN] instance */
327 BOOL fRegister
) /* [IN] TRUE = register, FALSE = unregister */
331 WCHAR szFilterPath
[ 256 ];
332 WCHAR szCLSID
[ 256 ];
334 QUARTZ_GUIDtoString( szCLSID
, pclsid
);
335 lstrcpyW( szFilterPath
, QUARTZ_wszInstance
);
336 QUARTZ_CatPathSepW( szFilterPath
);
337 lstrcatW( szFilterPath
, ( lpInstance
!= NULL
) ? lpInstance
: szCLSID
);
341 hr
= QUARTZ_OpenCLSIDKey(
342 &hKey
, KEY_ALL_ACCESS
, TRUE
,
343 pguidFilterCategory
, szFilterPath
);
347 if ( QUARTZ_RegSetValueString(
348 hKey
, QUARTZ_wszCLSID
, szCLSID
) != ERROR_SUCCESS
)
350 if ( pbFilterData
!= NULL
&& cbFilterData
> 0 &&
351 QUARTZ_RegSetValueBinary(
352 hKey
, QUARTZ_wszFilterData
,
353 pbFilterData
, cbFilterData
) != ERROR_SUCCESS
)
355 if ( lpFriendlyName
!= NULL
&& QUARTZ_RegSetValueString(
356 hKey
, QUARTZ_wszFriendlyName
,
357 lpFriendlyName
) != ERROR_SUCCESS
)
366 hr
= QUARTZ_OpenCLSIDKey(
367 &hKey
, KEY_ALL_ACCESS
, FALSE
,
368 pguidFilterCategory
, szFilterPath
);
372 RegDeleteValueW( hKey
, QUARTZ_wszCLSID
);
373 RegDeleteValueW( hKey
, QUARTZ_wszFilterData
);
374 RegDeleteValueW( hKey
, QUARTZ_wszFriendlyName
);
380 /* I think key should be deleted only if no subkey exists. */
381 FIXME( "unregister category %s filter %s - key should be removed!\n",
382 debugstr_guid(pguidFilterCategory
),
383 debugstr_guid(pclsid
) );