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)) *dwNr=atoi(sNum);
108 ParseFieldA (szDest, 1, szDest, len);
113 TRACE("-- %s %li\n", szDest, *dwNr );
117 /***************************************************************************************
118 * HCR_GetClassName [internal]
120 * Gets the name of a registred class
122 BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
128 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
129 riid->Data1, riid->Data2, riid->Data3,
130 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
131 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
133 TRACE("%s\n",xriid );
136 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
138 if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
145 if (!ret || !szDest[0])
147 if(IsEqualIID(riid, &CLSID_ShellDesktop))
149 if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
152 else if (IsEqualIID(riid, &CLSID_MyComputer))
154 if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
159 TRACE("-- %s\n", szDest);
164 /***************************************************************************************
165 * HCR_GetFolderAttributes [internal]
167 * gets the folder attributes of a class
170 * verify the defaultvalue for *szDest
172 BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
178 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
179 riid->Data1, riid->Data2, riid->Data3,
180 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
181 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
182 TRACE("%s\n",xriid );
184 if (!szDest) return FALSE;
185 *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
187 strcat (xriid, "\\ShellFolder");
189 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
194 if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
202 TRACE("-- 0x%08lx\n", attributes);
204 *szDest = attributes;
210 { ICOM_VFIELD(IQueryAssociations);
212 } IQueryAssociationsImpl;
214 static struct ICOM_VTABLE(IQueryAssociations) qavt;
216 /**************************************************************************
217 * IQueryAssociations_Constructor
219 IQueryAssociations* IQueryAssociations_Constructor(void)
221 IQueryAssociationsImpl* ei;
223 ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
225 ICOM_VTBL(ei) = &qavt;
229 return (IQueryAssociations *)ei;
231 /**************************************************************************
232 * IQueryAssociations_QueryInterface
234 static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
235 IQueryAssociations * iface,
239 ICOM_THIS(IQueryAssociationsImpl,iface);
241 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
245 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
249 else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
251 *ppvObj = (IQueryAssociations*)This;
256 IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
257 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
260 TRACE("-- Interface: E_NOINTERFACE\n");
261 return E_NOINTERFACE;
264 /**************************************************************************
265 * IQueryAssociations_AddRef
267 static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
269 ICOM_THIS(IQueryAssociationsImpl,iface);
271 TRACE("(%p)->(count=%lu)\n",This, This->ref );
275 return ++(This->ref);
277 /**************************************************************************
278 * IQueryAssociations_Release
280 static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
282 ICOM_THIS(IQueryAssociationsImpl,iface);
284 TRACE("(%p)->()\n",This);
290 TRACE(" destroying IExtractIcon(%p)\n",This);
291 HeapFree(GetProcessHeap(),0,This);
297 static HRESULT WINAPI IQueryAssociations_fnInit(
298 IQueryAssociations * iface,
307 static HRESULT WINAPI IQueryAssociations_fnGetString(
308 IQueryAssociations * iface,
318 static HRESULT WINAPI IQueryAssociations_fnGetKey(
319 IQueryAssociations * iface,
328 static HRESULT WINAPI IQueryAssociations_fnGetData(
329 IQueryAssociations * iface,
338 static HRESULT WINAPI IQueryAssociations_fnGetEnum(
339 IQueryAssociations * iface,
349 static struct ICOM_VTABLE(IQueryAssociations) qavt =
351 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
352 IQueryAssociations_fnQueryInterface,
353 IQueryAssociations_fnAddRef,
354 IQueryAssociations_fnRelease,
355 IQueryAssociations_fnInit,
356 IQueryAssociations_fnGetString,
357 IQueryAssociations_fnGetKey,
358 IQueryAssociations_fnGetData,
359 IQueryAssociations_fnGetEnum