Update shell xxxAW wrapper prototypes for fixed SHLWAPI functions.
[wine] / dlls / msdmo / dmoreg.c
1 /*
2  * Implements dmoreg APIs.
3  *
4  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
5  *
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.
10  *
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.
15  *
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
19  *
20  *      FIXME - stub.
21  */
22
23 #include "config.h"
24
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "winerror.h"
31 #include "wine/obj_base.h"
32 #include "mediaobj.h"
33 #include "dmoreg.h"
34
35 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
37
38
39 /*
40
41   NOTE: You may build this dll as a native dll and
42         use with native non-DirectX8 environment(NT 4.0 etc).
43
44  */
45
46 static const WCHAR wszDMOPath[] =
47 {'D','i','r','e','c','t','S','h','o','w','\\',
48  'M','e','d','i','a','O','b','j','e','c','t','s',0};
49 static const WCHAR wszDMOCatPath[] =
50 {'D','i','r','e','c','t','S','h','o','w','\\',
51  'M','e','d','i','a','O','b','j','e','c','t','s','\\',
52  'C','a','t','e','g','o','r','i','e','s',0};
53 static const WCHAR wszInputTypes[] =
54 {'I','n','p','u','t','T','y','p','e','s',0};
55 static const WCHAR wszOutputTypes[] =
56 {'O','u','t','p','u','t','T','y','p','e','s',0};
57
58 static const WCHAR QUARTZ_wszREG_SZ[] = {'R','E','G','_','S','Z',0};
59
60 /*************************************************************************/
61
62
63 static void QUARTZ_CatPathSepW( WCHAR* pBuf )
64 {
65         int     len = lstrlenW(pBuf);
66         pBuf[len] = '\\';
67         pBuf[len+1] = 0;
68 }
69
70 static void QUARTZ_GUIDtoString( WCHAR* pBuf, const GUID* pguid )
71 {
72         /* W"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}" */
73         static const WCHAR wszFmt[] =
74                 {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X',
75                  '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%',
76                  '0','2','X','%','0','2','X','%','0','2','X','%','0','2','X',
77                  '%','0','2','X','}',0};
78
79         wsprintfW( pBuf, wszFmt,
80                 pguid->Data1, pguid->Data2, pguid->Data3,
81                 pguid->Data4[0], pguid->Data4[1],
82                 pguid->Data4[2], pguid->Data4[3],
83                 pguid->Data4[4], pguid->Data4[5],
84                 pguid->Data4[6], pguid->Data4[7] );
85 }
86
87 static
88 LONG QUARTZ_RegOpenKeyW(
89         HKEY hkRoot, LPCWSTR lpszPath,
90         REGSAM rsAccess, HKEY* phKey,
91         BOOL fCreateKey )
92 {
93         DWORD   dwDisp;
94         WCHAR   wszREG_SZ[ sizeof(QUARTZ_wszREG_SZ)/sizeof(QUARTZ_wszREG_SZ[0]) ];
95
96         memcpy(wszREG_SZ,QUARTZ_wszREG_SZ,sizeof(QUARTZ_wszREG_SZ) );
97
98         if ( fCreateKey )
99                 return RegCreateKeyExW(
100                         hkRoot, lpszPath, 0, wszREG_SZ,
101                         REG_OPTION_NON_VOLATILE, rsAccess, NULL, phKey, &dwDisp );
102         else
103                 return RegOpenKeyExW(
104                         hkRoot, lpszPath, 0, rsAccess, phKey );
105 }
106
107 static
108 LONG QUARTZ_RegSetValueString(
109         HKEY hKey, LPCWSTR lpszName, LPCWSTR lpValue )
110 {
111         return RegSetValueExW(
112                 hKey, lpszName, 0, REG_SZ,
113                 (const BYTE*)lpValue,
114                 sizeof(lpValue[0]) * (lstrlenW(lpValue)+1) );
115 }
116
117 static
118 LONG QUARTZ_RegSetValueBinary(
119         HKEY hKey, LPCWSTR lpszName,
120         const BYTE* pData, int iLenOfData )
121 {
122         return RegSetValueExW(
123                 hKey, lpszName, 0, REG_BINARY, pData, iLenOfData );
124 }
125
126
127 /*************************************************************************/
128
129
130 HRESULT WINAPI DMOEnum( REFGUID rguidCat, DWORD dwFlags, DWORD dwCountOfInTypes, const DMO_PARTIAL_MEDIATYPE* pInTypes, DWORD dwCountOfOutTypes, const DMO_PARTIAL_MEDIATYPE* pOutTypes, IEnumDMO** ppEnum )
131 {
132         FIXME( "stub!\n" );
133         return E_NOTIMPL;
134 }
135
136 HRESULT WINAPI DMOGetName( REFCLSID rclsid, WCHAR* pwszName )
137 {
138         FIXME( "stub!\n" );
139         return E_NOTIMPL;
140 }
141
142
143 HRESULT WINAPI DMOGetTypes( REFCLSID rclsid, unsigned long ulInputTypesReq, unsigned long* pulInputTypesRet, unsigned long ulOutputTypesReq, unsigned long* pulOutputTypesRet, const DMO_PARTIAL_MEDIATYPE* pOutTypes )
144 {
145         FIXME( "stub!\n" );
146         return E_NOTIMPL;
147 }
148
149 HRESULT WINAPI DMOGuidToStrA( void* pv1, void* pv2 )
150 {
151         FIXME( "(%p,%p) stub!\n", pv1, pv2 );
152         return E_NOTIMPL;
153 }
154
155 HRESULT WINAPI DMOGuidToStrW( void* pv1, void* pv2 )
156 {
157         FIXME( "(%p,%p) stub!\n", pv1, pv2 );
158         return E_NOTIMPL;
159 }
160
161 HRESULT WINAPI DMORegister( LPCWSTR pwszName, REFCLSID rclsid, REFGUID rguidCat, DWORD dwFlags, DWORD dwCountOfInTypes, const DMO_PARTIAL_MEDIATYPE* pInTypes, DWORD dwCountOfOutTypes, const DMO_PARTIAL_MEDIATYPE* pOutTypes )
162 {
163         HRESULT hr;
164         HKEY    hKey;
165         WCHAR   wszPath[1024];
166
167         FIXME( "() not tested!\n" );
168
169         hr = S_OK;
170
171         memcpy(wszPath,wszDMOPath,sizeof(wszDMOPath));
172         QUARTZ_CatPathSepW(wszPath);
173         QUARTZ_GUIDtoString(&wszPath[lstrlenW(wszPath)],rclsid);
174         if ( QUARTZ_RegOpenKeyW( HKEY_CLASSES_ROOT,
175                 wszPath, KEY_ALL_ACCESS, &hKey, TRUE ) != ERROR_SUCCESS )
176                 return E_FAIL;
177         if ( pwszName != NULL && QUARTZ_RegSetValueString(
178                         hKey, NULL, pwszName ) != ERROR_SUCCESS )
179                 hr = E_FAIL;
180         if ( dwCountOfInTypes > 0 && QUARTZ_RegSetValueBinary(
181                 hKey, wszInputTypes, (const BYTE*)pInTypes,
182                 dwCountOfInTypes * sizeof(DMO_PARTIAL_MEDIATYPE) ) != ERROR_SUCCESS )
183                 hr = E_FAIL;
184         if ( dwCountOfOutTypes > 0 && QUARTZ_RegSetValueBinary(
185                 hKey, wszOutputTypes, (const BYTE*)pOutTypes,
186                 dwCountOfOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE) ) != ERROR_SUCCESS )
187                 hr = E_FAIL;
188         RegCloseKey( hKey );
189         if ( FAILED(hr) )
190                 return hr;
191
192         memcpy(wszPath,wszDMOCatPath,sizeof(wszDMOCatPath));
193         QUARTZ_CatPathSepW(wszPath);
194         QUARTZ_GUIDtoString(&wszPath[lstrlenW(wszPath)],rguidCat);
195         QUARTZ_CatPathSepW(wszPath);
196         QUARTZ_GUIDtoString(&wszPath[lstrlenW(wszPath)],rclsid);
197         if ( QUARTZ_RegOpenKeyW( HKEY_CLASSES_ROOT,
198                 wszPath, KEY_ALL_ACCESS, &hKey, TRUE ) != ERROR_SUCCESS )
199                 return E_FAIL;
200         RegCloseKey( hKey );
201         if ( FAILED(hr) )
202                 return hr;
203
204         return S_OK;
205 }
206
207 HRESULT WINAPI DMOStrToGuidA( void* pv1, void* pv2 )
208 {
209         FIXME( "(%p,%p) stub!\n", pv1, pv2 );
210         return E_NOTIMPL;
211 }
212
213 HRESULT WINAPI DMOStrToGuidW( void* pv1, void* pv2 )
214 {
215         FIXME( "(%p,%p) stub!\n", pv1, pv2 );
216         return E_NOTIMPL;
217 }
218
219 HRESULT WINAPI DMOUnregister( REFCLSID rclsid, REFGUID rguidCat )
220 {
221         FIXME( "stub!\n" );
222
223         return E_NOTIMPL;
224 }
225
226
227