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