3 * (HKEY_CLASSES_ROOT - Stuff)
5 * Copyright 1998, 1999, 2000 Juergen Schmied
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "wine/port.h"
28 #include "wine/debug.h"
33 #include "shell32_main.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(shell);
40 #define MAX_EXTENSION_LENGTH 20
42 BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
44 char szTemp[MAX_EXTENSION_LENGTH + 2];
46 TRACE("%s %p\n",szExtension, szFileType );
48 /* added because we do not want to have double dots */
49 if (szExtension[0]=='.')
55 lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
57 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
61 if (RegQueryValueA(hkey,NULL,szFileType,&len))
69 } %s\n", szFileType );
73 BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
77 TRACE("%s %s\n",szClass, szVerb );
79 snprintf(sTemp, MAX_PATH, "%s\\shell\\%s\\command",szClass, szVerb);
81 if (ERROR_SUCCESS == SHGetValueA(HKEY_CLASSES_ROOT, sTemp, NULL, NULL, szDest, &len)) {
82 TRACE("-- %s\n", debugstr_a(szDest) );
87 /***************************************************************************************
88 * HCR_GetDefaultIcon [internal]
90 * Gets the icon for a filetype
92 BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
100 TRACE("%s\n",szClass );
102 sprintf(sTemp, "%s\\DefaultIcon",szClass);
104 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
106 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
108 if (dwType == REG_EXPAND_SZ)
110 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
111 strcpy(szDest, sTemp);
113 if (ParseFieldA (szDest, 2, sNum, 5))
116 *dwNr=0; /* sometimes the icon number is missing */
117 ParseFieldA (szDest, 1, szDest, len);
122 TRACE("-- %s %li\n", szDest, *dwNr );
126 /***************************************************************************************
127 * HCR_GetClassName [internal]
129 * Gets the name of a registred class
131 BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
137 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
138 riid->Data1, riid->Data2, riid->Data3,
139 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
140 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
142 TRACE("%s\n",xriid );
145 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
147 if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
154 if (!ret || !szDest[0])
156 if(IsEqualIID(riid, &CLSID_ShellDesktop))
158 if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
161 else if (IsEqualIID(riid, &CLSID_MyComputer))
163 if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
168 TRACE("-- %s\n", szDest);
173 /***************************************************************************************
174 * HCR_GetFolderAttributes [internal]
176 * gets the folder attributes of a class
179 * verify the defaultvalue for *szDest
181 BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
187 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
188 riid->Data1, riid->Data2, riid->Data3,
189 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
190 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
191 TRACE("%s\n",xriid );
193 if (!szDest) return FALSE;
194 *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
196 strcat (xriid, "\\ShellFolder");
198 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
203 if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
211 TRACE("-- 0x%08lx\n", attributes);
213 *szDest = attributes;
219 { ICOM_VFIELD(IQueryAssociations);
221 } IQueryAssociationsImpl;
223 static struct ICOM_VTABLE(IQueryAssociations) qavt;
225 /**************************************************************************
226 * IQueryAssociations_Constructor
228 IQueryAssociations* IQueryAssociations_Constructor(void)
230 IQueryAssociationsImpl* ei;
232 ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
234 ICOM_VTBL(ei) = &qavt;
237 return (IQueryAssociations *)ei;
239 /**************************************************************************
240 * IQueryAssociations_QueryInterface
242 static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
243 IQueryAssociations * iface,
247 ICOM_THIS(IQueryAssociationsImpl,iface);
249 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
253 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
257 else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
259 *ppvObj = (IQueryAssociations*)This;
264 IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
265 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
268 TRACE("-- Interface: E_NOINTERFACE\n");
269 return E_NOINTERFACE;
272 /**************************************************************************
273 * IQueryAssociations_AddRef
275 static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
277 ICOM_THIS(IQueryAssociationsImpl,iface);
279 TRACE("(%p)->(count=%lu)\n",This, This->ref );
281 return ++(This->ref);
283 /**************************************************************************
284 * IQueryAssociations_Release
286 static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
288 ICOM_THIS(IQueryAssociationsImpl,iface);
290 TRACE("(%p)->()\n",This);
294 TRACE(" destroying IExtractIcon(%p)\n",This);
295 HeapFree(GetProcessHeap(),0,This);
301 static HRESULT WINAPI IQueryAssociations_fnInit(
302 IQueryAssociations * iface,
311 static HRESULT WINAPI IQueryAssociations_fnGetString(
312 IQueryAssociations * iface,
322 static HRESULT WINAPI IQueryAssociations_fnGetKey(
323 IQueryAssociations * iface,
332 static HRESULT WINAPI IQueryAssociations_fnGetData(
333 IQueryAssociations * iface,
342 static HRESULT WINAPI IQueryAssociations_fnGetEnum(
343 IQueryAssociations * iface,
353 static struct ICOM_VTABLE(IQueryAssociations) qavt =
355 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
356 IQueryAssociations_fnQueryInterface,
357 IQueryAssociations_fnAddRef,
358 IQueryAssociations_fnRelease,
359 IQueryAssociations_fnInit,
360 IQueryAssociations_fnGetString,
361 IQueryAssociations_fnGetKey,
362 IQueryAssociations_fnGetData,
363 IQueryAssociations_fnGetEnum