3 * (HKEY_CLASSES_ROOT - Stuff)
10 #include "debugtools.h"
15 #include "shell32_main.h"
18 #include "wine/obj_queryassociations.h"
20 DEFAULT_DEBUG_CHANNEL(shell);
22 #define MAX_EXTENSION_LENGTH 20
24 BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
26 char szTemp[MAX_EXTENSION_LENGTH + 2];
28 TRACE("%s %p\n",szExtension, szFileType );
30 /* added because we do not want to have double dots */
31 if (szExtension[0]=='.')
37 lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
39 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
43 if (RegQueryValueA(hkey,NULL,szFileType,&len))
50 TRACE("-- %s\n", szFileType );
54 BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
61 TRACE("%s %s\n",szClass, szVerb );
63 sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
65 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
67 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
69 if (dwType == REG_EXPAND_SZ)
71 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
72 strcpy(szDest, sTemp);
78 TRACE("-- %s\n", szDest );
81 /***************************************************************************************
82 * HCR_GetDefaultIcon [internal]
84 * Gets the icon for a filetype
86 BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
94 TRACE("%s\n",szClass );
96 sprintf(sTemp, "%s\\DefaultIcon",szClass);
98 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
100 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
102 if (dwType == REG_EXPAND_SZ)
104 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
105 strcpy(szDest, sTemp);
107 if (ParseFieldA (szDest, 2, sNum, 5))
110 *dwNr=0; /* sometimes the icon number is missing */
111 ParseFieldA (szDest, 1, szDest, len);
116 TRACE("-- %s %li\n", szDest, *dwNr );
120 /***************************************************************************************
121 * HCR_GetClassName [internal]
123 * Gets the name of a registred class
125 BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
131 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
132 riid->Data1, riid->Data2, riid->Data3,
133 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
134 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
136 TRACE("%s\n",xriid );
139 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
141 if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
148 if (!ret || !szDest[0])
150 if(IsEqualIID(riid, &CLSID_ShellDesktop))
152 if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
155 else if (IsEqualIID(riid, &CLSID_MyComputer))
157 if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
162 TRACE("-- %s\n", szDest);
167 /***************************************************************************************
168 * HCR_GetFolderAttributes [internal]
170 * gets the folder attributes of a class
173 * verify the defaultvalue for *szDest
175 BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
181 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
182 riid->Data1, riid->Data2, riid->Data3,
183 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
184 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
185 TRACE("%s\n",xriid );
187 if (!szDest) return FALSE;
188 *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
190 strcat (xriid, "\\ShellFolder");
192 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
197 if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
205 TRACE("-- 0x%08lx\n", attributes);
207 *szDest = attributes;
213 { ICOM_VFIELD(IQueryAssociations);
215 } IQueryAssociationsImpl;
217 static struct ICOM_VTABLE(IQueryAssociations) qavt;
219 /**************************************************************************
220 * IQueryAssociations_Constructor
222 IQueryAssociations* IQueryAssociations_Constructor(void)
224 IQueryAssociationsImpl* ei;
226 ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
228 ICOM_VTBL(ei) = &qavt;
232 return (IQueryAssociations *)ei;
234 /**************************************************************************
235 * IQueryAssociations_QueryInterface
237 static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
238 IQueryAssociations * iface,
242 ICOM_THIS(IQueryAssociationsImpl,iface);
244 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
248 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
252 else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
254 *ppvObj = (IQueryAssociations*)This;
259 IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
260 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
263 TRACE("-- Interface: E_NOINTERFACE\n");
264 return E_NOINTERFACE;
267 /**************************************************************************
268 * IQueryAssociations_AddRef
270 static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
272 ICOM_THIS(IQueryAssociationsImpl,iface);
274 TRACE("(%p)->(count=%lu)\n",This, This->ref );
278 return ++(This->ref);
280 /**************************************************************************
281 * IQueryAssociations_Release
283 static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
285 ICOM_THIS(IQueryAssociationsImpl,iface);
287 TRACE("(%p)->()\n",This);
293 TRACE(" destroying IExtractIcon(%p)\n",This);
294 HeapFree(GetProcessHeap(),0,This);
300 static HRESULT WINAPI IQueryAssociations_fnInit(
301 IQueryAssociations * iface,
310 static HRESULT WINAPI IQueryAssociations_fnGetString(
311 IQueryAssociations * iface,
321 static HRESULT WINAPI IQueryAssociations_fnGetKey(
322 IQueryAssociations * iface,
331 static HRESULT WINAPI IQueryAssociations_fnGetData(
332 IQueryAssociations * iface,
341 static HRESULT WINAPI IQueryAssociations_fnGetEnum(
342 IQueryAssociations * iface,
352 static struct ICOM_VTABLE(IQueryAssociations) qavt =
354 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
355 IQueryAssociations_fnQueryInterface,
356 IQueryAssociations_fnAddRef,
357 IQueryAssociations_fnRelease,
358 IQueryAssociations_fnInit,
359 IQueryAssociations_fnGetString,
360 IQueryAssociations_fnGetKey,
361 IQueryAssociations_fnGetData,
362 IQueryAssociations_fnGetEnum