source: trunk/src/shell32/classes.c@ 5655

Last change on this file since 5655 was 4121, checked in by sandervl, 25 years ago

complete merge with shell32 from wine 20000801

File size: 8.0 KB
Line 
1/* $Id: classes.c,v 1.1 2000-08-30 13:52:50 sandervl Exp $ */
2/*
3 * file type mapping
4 * (HKEY_CLASSES_ROOT - Stuff)
5 *
6 *
7 */
8#ifdef __WIN32OS2__
9#define ICOM_CINTERFACE 1
10#include <odin.h>
11#endif
12#include <stdlib.h>
13#include <string.h>
14#include <stdio.h>
15#include "debugtools.h"
16#include "winerror.h"
17#include "winreg.h"
18
19#include "wine/obj_queryassociations.h"
20#include "shlobj.h"
21#include "shell32_main.h"
22#include "shlguid.h"
23#include "shresdef.h"
24
25DEFAULT_DEBUG_CHANNEL(shell);
26
27#define MAX_EXTENSION_LENGTH 20
28
29BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
30{ HKEY hkey;
31 char szTemp[MAX_EXTENSION_LENGTH + 2];
32
33 TRACE("%s %p\n",szExtension, szFileType );
34
35 if (bPrependDot)
36 strcpy(szTemp, ".");
37
38 lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
39
40 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
41 { return FALSE;
42 }
43
44 if (RegQueryValueA(hkey,NULL,szFileType,&len))
45 { RegCloseKey(hkey);
46 return FALSE;
47 }
48
49 RegCloseKey(hkey);
50
51 TRACE("-- %s\n", szFileType );
52
53 return TRUE;
54}
55BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
56{
57 HKEY hkey;
58 char sTemp[MAX_PATH];
59 DWORD dwType;
60 BOOL ret = FALSE;
61
62 TRACE("%s %s\n",szClass, szVerb );
63
64 sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
65
66 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
67 {
68 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
69 {
70 if (dwType == REG_EXPAND_SZ)
71 {
72 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
73 strcpy(szDest, sTemp);
74 }
75 ret = TRUE;
76 }
77 RegCloseKey(hkey);
78 }
79 TRACE("-- %s\n", szDest );
80 return ret;
81}
82/***************************************************************************************
83* HCR_GetDefaultIcon [internal]
84*
85* Gets the icon for a filetype
86*/
87BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
88{
89 HKEY hkey;
90 char sTemp[MAX_PATH];
91 char sNum[5];
92 DWORD dwType;
93 BOOL ret = FALSE;
94
95 TRACE("%s\n",szClass );
96
97 sprintf(sTemp, "%s\\DefaultIcon",szClass);
98
99 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
100 {
101 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
102 {
103 if (dwType == REG_EXPAND_SZ)
104 {
105 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
106 strcpy(szDest, sTemp);
107 }
108 if (ParseFieldA (szDest, 2, sNum, 5)) *dwNr=atoi(sNum);
109 ParseFieldA (szDest, 1, szDest, len);
110 ret = TRUE;
111 }
112 RegCloseKey(hkey);
113 }
114 TRACE("-- %s %li\n", szDest, *dwNr );
115 return ret;
116}
117
118/***************************************************************************************
119* HCR_GetClassName [internal]
120*
121* Gets the name of a registred class
122*/
123BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
124{ HKEY hkey;
125 char xriid[50];
126 BOOL ret = FALSE;
127 DWORD buflen = len;
128
129 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
130 riid->Data1, riid->Data2, riid->Data3,
131 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
132 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
133
134 TRACE("%s\n",xriid );
135
136 szDest[0] = 0;
137 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
138 {
139 if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
140 {
141 ret = TRUE;
142 }
143 RegCloseKey(hkey);
144 }
145
146 if (!ret || !szDest[0])
147 {
148 if(IsEqualIID(riid, &CLSID_ShellDesktop))
149 {
150 if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
151 ret = TRUE;
152 }
153 else if (IsEqualIID(riid, &CLSID_MyComputer))
154 {
155 if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
156 ret = TRUE;
157 }
158 }
159
160 TRACE("-- %s\n", szDest);
161
162 return ret;
163}
164
165/***************************************************************************************
166* HCR_GetFolderAttributes [internal]
167*
168* gets the folder attributes of a class
169*
170* FIXME
171* verify the defaultvalue for *szDest
172*/
173BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
174{ HKEY hkey;
175 char xriid[60];
176 DWORD attributes;
177 DWORD len = 4;
178
179 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
180 riid->Data1, riid->Data2, riid->Data3,
181 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
182 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
183 TRACE("%s\n",xriid );
184
185 if (!szDest) return FALSE;
186 *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
187
188 strcat (xriid, "\\ShellFolder");
189
190 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
191 {
192 return FALSE;
193 }
194
195 if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
196 {
197 RegCloseKey(hkey);
198 return FALSE;
199 }
200
201 RegCloseKey(hkey);
202
203 TRACE("-- 0x%08lx\n", attributes);
204
205 *szDest = attributes;
206
207 return TRUE;
208}
209
210typedef struct
211{ ICOM_VFIELD(IQueryAssociations);
212 DWORD ref;
213} IQueryAssociationsImpl;
214
215static struct ICOM_VTABLE(IQueryAssociations) qavt;
216
217/**************************************************************************
218* IQueryAssociations_Constructor
219*/
220IQueryAssociations* IQueryAssociations_Constructor(void)
221{
222 IQueryAssociationsImpl* ei;
223
224 ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
225 ei->ref=1;
226 ICOM_VTBL(ei) = &qavt;
227
228 TRACE("(%p)\n",ei);
229 shell32_ObjCount++;
230 return (IQueryAssociations *)ei;
231}
232/**************************************************************************
233 * IQueryAssociations_QueryInterface
234 */
235static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
236 IQueryAssociations * iface,
237 REFIID riid,
238 LPVOID *ppvObj)
239{
240 ICOM_THIS(IQueryAssociationsImpl,iface);
241
242 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
243
244 *ppvObj = NULL;
245
246 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
247 {
248 *ppvObj = This;
249 }
250 else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
251 {
252 *ppvObj = (IQueryAssociations*)This;
253 }
254
255 if(*ppvObj)
256 {
257 IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
258 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
259 return S_OK;
260 }
261 TRACE("-- Interface: E_NOINTERFACE\n");
262 return E_NOINTERFACE;
263}
264
265/**************************************************************************
266* IQueryAssociations_AddRef
267*/
268static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
269{
270 ICOM_THIS(IQueryAssociationsImpl,iface);
271
272 TRACE("(%p)->(count=%lu)\n",This, This->ref );
273
274 shell32_ObjCount++;
275
276 return ++(This->ref);
277}
278/**************************************************************************
279* IQueryAssociations_Release
280*/
281static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
282{
283 ICOM_THIS(IQueryAssociationsImpl,iface);
284
285 TRACE("(%p)->()\n",This);
286
287 shell32_ObjCount--;
288
289 if (!--(This->ref))
290 {
291 TRACE(" destroying IExtractIcon(%p)\n",This);
292 HeapFree(GetProcessHeap(),0,This);
293 return 0;
294 }
295 return This->ref;
296}
297
298static HRESULT WINAPI IQueryAssociations_fnInit(
299 IQueryAssociations * iface,
300 ASSOCF flags,
301 LPCWSTR pszAssoc,
302 HKEY hkProgid,
303 HWND hwnd)
304{
305 return E_NOTIMPL;
306}
307
308static HRESULT WINAPI IQueryAssociations_fnGetString(
309 IQueryAssociations * iface,
310 ASSOCF flags,
311 ASSOCSTR str,
312 LPCWSTR pszExtra,
313 LPWSTR pszOut,
314 DWORD *pcchOut)
315{
316 return E_NOTIMPL;
317}
318
319static HRESULT WINAPI IQueryAssociations_fnGetKey(
320 IQueryAssociations * iface,
321 ASSOCF flags,
322 ASSOCKEY key,
323 LPCWSTR pszExtra,
324 HKEY *phkeyOut)
325{
326 return E_NOTIMPL;
327}
328
329static HRESULT WINAPI IQueryAssociations_fnGetData(
330 IQueryAssociations * iface,
331 ASSOCF flags,
332 ASSOCDATA data,
333 LPCWSTR pszExtra,
334 LPVOID pvOut,
335 DWORD *pcbOut)
336{
337 return E_NOTIMPL;
338}
339static HRESULT WINAPI IQueryAssociations_fnGetEnum(
340 IQueryAssociations * iface,
341 ASSOCF flags,
342 ASSOCENUM assocenum,
343 LPCWSTR pszExtra,
344 REFIID riid,
345 LPVOID *ppvOut)
346{
347 return E_NOTIMPL;
348}
349
350static struct ICOM_VTABLE(IQueryAssociations) qavt =
351{
352 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
353 IQueryAssociations_fnQueryInterface,
354 IQueryAssociations_fnAddRef,
355 IQueryAssociations_fnRelease,
356 IQueryAssociations_fnInit,
357 IQueryAssociations_fnGetString,
358 IQueryAssociations_fnGetKey,
359 IQueryAssociations_fnGetData,
360 IQueryAssociations_fnGetEnum
361};
Note: See TracBrowser for help on using the repository browser.