3 * (HKEY_CLASSES_ROOT - Stuff)
10 #include "debugtools.h"
14 #include "wine/obj_queryassociations.h"
16 #include "shell32_main.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 );
33 lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
35 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
39 if (RegQueryValueA(hkey,NULL,szFileType,&len))
46 TRACE("-- %s\n", szFileType );
50 BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
57 TRACE("%s %s\n",szClass, szVerb );
59 sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
61 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
63 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
65 if (dwType == REG_EXPAND_SZ)
67 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
68 strcpy(szDest, sTemp);
74 TRACE("-- %s\n", szDest );
77 /***************************************************************************************
78 * HCR_GetDefaultIcon [internal]
80 * Gets the icon for a filetype
82 BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
90 TRACE("%s\n",szClass );
92 sprintf(sTemp, "%s\\DefaultIcon",szClass);
94 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
96 if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
98 if (dwType == REG_EXPAND_SZ)
100 ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
101 strcpy(szDest, sTemp);
103 if (ParseFieldA (szDest, 2, sNum, 5)) *dwNr=atoi(sNum);
104 ParseFieldA (szDest, 1, szDest, len);
109 TRACE("-- %s %li\n", szDest, *dwNr );
113 /***************************************************************************************
114 * HCR_GetClassName [internal]
116 * Gets the name of a registred class
118 BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
124 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
125 riid->Data1, riid->Data2, riid->Data3,
126 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
127 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
129 TRACE("%s\n",xriid );
132 if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
134 if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
141 if (!ret || !szDest[0])
143 if(IsEqualIID(riid, &CLSID_ShellDesktop))
145 if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
148 else if (IsEqualIID(riid, &CLSID_MyComputer))
150 if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
155 TRACE("-- %s\n", szDest);
160 /***************************************************************************************
161 * HCR_GetFolderAttributes [internal]
163 * gets the folder attributes of a class
166 * verify the defaultvalue for *szDest
168 BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
174 sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
175 riid->Data1, riid->Data2, riid->Data3,
176 riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
177 riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
178 TRACE("%s\n",xriid );
180 if (!szDest) return FALSE;
181 *szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
183 strcat (xriid, "\\ShellFolder");
185 if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
190 if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
198 TRACE("-- 0x%08lx\n", attributes);
200 *szDest = attributes;
206 { ICOM_VFIELD(IQueryAssociations);
208 } IQueryAssociationsImpl;
210 static struct ICOM_VTABLE(IQueryAssociations) qavt;
212 /**************************************************************************
213 * IQueryAssociations_Constructor
215 IQueryAssociations* IQueryAssociations_Constructor(void)
217 IQueryAssociationsImpl* ei;
219 ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
221 ICOM_VTBL(ei) = &qavt;
225 return (IQueryAssociations *)ei;
227 /**************************************************************************
228 * IQueryAssociations_QueryInterface
230 static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
231 IQueryAssociations * iface,
235 ICOM_THIS(IQueryAssociationsImpl,iface);
237 TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
241 if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
245 else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
247 *ppvObj = (IQueryAssociations*)This;
252 IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
253 TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
256 TRACE("-- Interface: E_NOINTERFACE\n");
257 return E_NOINTERFACE;
260 /**************************************************************************
261 * IQueryAssociations_AddRef
263 static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
265 ICOM_THIS(IQueryAssociationsImpl,iface);
267 TRACE("(%p)->(count=%lu)\n",This, This->ref );
271 return ++(This->ref);
273 /**************************************************************************
274 * IQueryAssociations_Release
276 static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
278 ICOM_THIS(IQueryAssociationsImpl,iface);
280 TRACE("(%p)->()\n",This);
286 TRACE(" destroying IExtractIcon(%p)\n",This);
287 HeapFree(GetProcessHeap(),0,This);
293 static HRESULT WINAPI IQueryAssociations_fnInit(
294 IQueryAssociations * iface,
303 static HRESULT WINAPI IQueryAssociations_fnGetString(
304 IQueryAssociations * iface,
314 static HRESULT WINAPI IQueryAssociations_fnGetKey(
315 IQueryAssociations * iface,
324 static HRESULT WINAPI IQueryAssociations_fnGetData(
325 IQueryAssociations * iface,
334 static HRESULT WINAPI IQueryAssociations_fnGetEnum(
335 IQueryAssociations * iface,
345 static struct ICOM_VTABLE(IQueryAssociations) qavt =
347 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
348 IQueryAssociations_fnQueryInterface,
349 IQueryAssociations_fnAddRef,
350 IQueryAssociations_fnRelease,
351 IQueryAssociations_fnInit,
352 IQueryAssociations_fnGetString,
353 IQueryAssociations_fnGetKey,
354 IQueryAssociations_fnGetData,
355 IQueryAssociations_fnGetEnum