1998-11-22 18:26:23 +00:00
|
|
|
/*
|
2002-05-31 23:06:46 +00:00
|
|
|
* file type mapping
|
1998-11-22 18:26:23 +00:00
|
|
|
* (HKEY_CLASSES_ROOT - Stuff)
|
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* Copyright 1998, 1999, 2000 Juergen Schmied
|
1998-11-22 18:26:23 +00:00
|
|
|
*
|
2002-03-09 23:29:33 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1998-11-22 18:26:23 +00:00
|
|
|
*/
|
2002-03-09 23:29:33 +00:00
|
|
|
|
1998-11-22 18:26:23 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-02-10 22:15:21 +00:00
|
|
|
#include <stdio.h>
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1998-11-22 18:26:23 +00:00
|
|
|
#include "winerror.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
#include "winreg.h"
|
1998-11-22 18:26:23 +00:00
|
|
|
|
1999-01-23 14:12:48 +00:00
|
|
|
#include "shlobj.h"
|
1998-11-22 18:26:23 +00:00
|
|
|
#include "shell32_main.h"
|
1999-08-15 14:24:49 +00:00
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shresdef.h"
|
2002-07-24 01:56:03 +00:00
|
|
|
#include "shlwapi.h"
|
1998-11-22 18:26:23 +00:00
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 14:56:29 +00:00
|
|
|
|
1999-07-25 12:19:12 +00:00
|
|
|
#define MAX_EXTENSION_LENGTH 20
|
|
|
|
|
1999-08-15 14:24:49 +00:00
|
|
|
BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
|
1998-11-22 18:26:23 +00:00
|
|
|
{ HKEY hkey;
|
1999-07-25 12:19:12 +00:00
|
|
|
char szTemp[MAX_EXTENSION_LENGTH + 2];
|
1998-11-22 18:26:23 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("%s %p\n",szExtension, szFileType );
|
1998-12-11 10:58:48 +00:00
|
|
|
|
2001-10-23 00:25:15 +00:00
|
|
|
/* added because we do not want to have double dots */
|
|
|
|
if (szExtension[0]=='.')
|
|
|
|
bPrependDot=0;
|
|
|
|
|
1999-08-15 14:24:49 +00:00
|
|
|
if (bPrependDot)
|
|
|
|
strcpy(szTemp, ".");
|
|
|
|
|
|
|
|
lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-07-25 12:19:12 +00:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
1998-11-22 18:26:23 +00:00
|
|
|
{ return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-26 11:11:13 +00:00
|
|
|
if (RegQueryValueA(hkey,NULL,szFileType,&len))
|
1998-11-22 18:26:23 +00:00
|
|
|
{ RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
1998-11-22 18:26:23 +00:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2002-07-24 01:56:03 +00:00
|
|
|
TRACE("--UE;
|
|
|
|
} %s\n", szFileType );
|
1998-11-22 18:26:23 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
|
2000-06-24 12:56:08 +00:00
|
|
|
{
|
|
|
|
char sTemp[MAX_PATH];
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("%s %s\n",szClass, szVerb );
|
1998-12-11 10:58:48 +00:00
|
|
|
|
2002-07-24 01:56:03 +00:00
|
|
|
snprintf(sTemp, MAX_PATH, "%s\\shell\\%s\\command",szClass, szVerb);
|
1998-12-11 10:58:48 +00:00
|
|
|
|
2002-07-24 01:56:03 +00:00
|
|
|
if (ERROR_SUCCESS == SHGetValueA(HKEY_CLASSES_ROOT, sTemp, NULL, NULL, szDest, &len)) {
|
|
|
|
TRACE("-- %s\n", debugstr_a(szDest) );
|
|
|
|
return TRUE;
|
1998-12-11 10:58:48 +00:00
|
|
|
}
|
2002-07-24 01:56:03 +00:00
|
|
|
return FALSE;
|
1998-12-11 10:58:48 +00:00
|
|
|
}
|
1998-12-14 17:33:00 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetDefaultIcon [internal]
|
|
|
|
*
|
|
|
|
* Gets the icon for a filetype
|
|
|
|
*/
|
1999-02-26 11:11:13 +00:00
|
|
|
BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
|
2000-06-24 12:56:08 +00:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
char sTemp[MAX_PATH];
|
1998-12-14 17:33:00 +00:00
|
|
|
char sNum[5];
|
2000-06-24 12:56:08 +00:00
|
|
|
DWORD dwType;
|
|
|
|
BOOL ret = FALSE;
|
1998-12-14 17:33:00 +00:00
|
|
|
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("%s\n",szClass );
|
1998-12-14 17:33:00 +00:00
|
|
|
|
|
|
|
sprintf(sTemp, "%s\\DefaultIcon",szClass);
|
|
|
|
|
2000-06-24 12:56:08 +00:00
|
|
|
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
|
|
|
{
|
|
|
|
if (!RegQueryValueExA(hkey, NULL, 0, &dwType, szDest, &len))
|
|
|
|
{
|
|
|
|
if (dwType == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
|
|
|
|
strcpy(szDest, sTemp);
|
|
|
|
}
|
2002-02-19 18:31:22 +00:00
|
|
|
if (ParseFieldA (szDest, 2, sNum, 5))
|
|
|
|
*dwNr=atoi(sNum);
|
|
|
|
else
|
|
|
|
*dwNr=0; /* sometimes the icon number is missing */
|
2000-06-24 12:56:08 +00:00
|
|
|
ParseFieldA (szDest, 1, szDest, len);
|
|
|
|
ret = TRUE;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
2000-06-24 12:56:08 +00:00
|
|
|
RegCloseKey(hkey);
|
1998-12-14 17:33:00 +00:00
|
|
|
}
|
1999-06-12 15:45:58 +00:00
|
|
|
TRACE("-- %s %li\n", szDest, *dwNr );
|
2000-06-24 12:56:08 +00:00
|
|
|
return ret;
|
1999-07-25 12:19:12 +00:00
|
|
|
}
|
1998-12-14 17:33:00 +00:00
|
|
|
|
1999-07-25 12:19:12 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetClassName [internal]
|
|
|
|
*
|
|
|
|
* Gets the name of a registred class
|
|
|
|
*/
|
|
|
|
BOOL HCR_GetClassName (REFIID riid, LPSTR szDest, DWORD len)
|
|
|
|
{ HKEY hkey;
|
|
|
|
char xriid[50];
|
1999-08-15 14:24:49 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
1999-07-25 12:19:12 +00:00
|
|
|
|
2000-06-23 16:13:33 +00:00
|
|
|
sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
|
|
|
riid->Data1, riid->Data2, riid->Data3,
|
|
|
|
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
|
|
|
|
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
|
1999-07-25 12:19:12 +00:00
|
|
|
|
|
|
|
TRACE("%s\n",xriid );
|
|
|
|
|
2000-02-20 18:38:19 +00:00
|
|
|
szDest[0] = 0;
|
1999-08-15 14:24:49 +00:00
|
|
|
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|
|
|
{
|
|
|
|
if (!RegQueryValueExA(hkey,"",0,NULL,szDest,&len))
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
1999-07-25 12:19:12 +00:00
|
|
|
}
|
|
|
|
|
1999-08-15 14:24:49 +00:00
|
|
|
if (!ret || !szDest[0])
|
2002-05-31 23:06:46 +00:00
|
|
|
{
|
1999-08-15 14:24:49 +00:00
|
|
|
if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
|
|
|
{
|
2000-02-20 18:38:19 +00:00
|
|
|
if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
|
|
|
|
ret = TRUE;
|
1999-08-15 14:24:49 +00:00
|
|
|
}
|
1999-11-23 22:31:18 +00:00
|
|
|
else if (IsEqualIID(riid, &CLSID_MyComputer))
|
1999-08-15 14:24:49 +00:00
|
|
|
{
|
2000-02-20 18:38:19 +00:00
|
|
|
if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
|
|
|
|
ret = TRUE;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
1999-08-15 14:24:49 +00:00
|
|
|
}
|
1999-07-25 12:19:12 +00:00
|
|
|
|
|
|
|
TRACE("-- %s\n", szDest);
|
|
|
|
|
1999-08-15 14:24:49 +00:00
|
|
|
return ret;
|
1999-07-25 12:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetFolderAttributes [internal]
|
|
|
|
*
|
|
|
|
* gets the folder attributes of a class
|
1999-11-23 22:31:18 +00:00
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* verify the defaultvalue for *szDest
|
1999-07-25 12:19:12 +00:00
|
|
|
*/
|
|
|
|
BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
|
|
|
{ HKEY hkey;
|
|
|
|
char xriid[60];
|
|
|
|
DWORD attributes;
|
|
|
|
DWORD len = 4;
|
|
|
|
|
2000-06-23 16:13:33 +00:00
|
|
|
sprintf( xriid, "CLSID\\{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
|
|
|
riid->Data1, riid->Data2, riid->Data3,
|
|
|
|
riid->Data4[0], riid->Data4[1], riid->Data4[2], riid->Data4[3],
|
|
|
|
riid->Data4[4], riid->Data4[5], riid->Data4[6], riid->Data4[7] );
|
1999-07-25 12:19:12 +00:00
|
|
|
TRACE("%s\n",xriid );
|
|
|
|
|
1999-11-23 22:31:18 +00:00
|
|
|
if (!szDest) return FALSE;
|
|
|
|
*szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
|
2002-05-31 23:06:46 +00:00
|
|
|
|
1999-07-25 12:19:12 +00:00
|
|
|
strcat (xriid, "\\ShellFolder");
|
|
|
|
|
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT,xriid,0,KEY_READ,&hkey))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegQueryValueExA(hkey,"Attributes",0,NULL,(LPBYTE)&attributes,&len))
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
1999-08-15 14:24:49 +00:00
|
|
|
}
|
1999-07-25 12:19:12 +00:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
TRACE("-- 0x%08lx\n", attributes);
|
|
|
|
|
|
|
|
*szDest = attributes;
|
|
|
|
|
|
|
|
return TRUE;
|
1998-12-14 17:33:00 +00:00
|
|
|
}
|
1998-11-22 18:26:23 +00:00
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
typedef struct
|
2000-04-28 20:22:33 +00:00
|
|
|
{ ICOM_VFIELD(IQueryAssociations);
|
|
|
|
DWORD ref;
|
|
|
|
} IQueryAssociationsImpl;
|
|
|
|
|
|
|
|
static struct ICOM_VTABLE(IQueryAssociations) qavt;
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_Constructor
|
|
|
|
*/
|
|
|
|
IQueryAssociations* IQueryAssociations_Constructor(void)
|
|
|
|
{
|
|
|
|
IQueryAssociationsImpl* ei;
|
|
|
|
|
|
|
|
ei=(IQueryAssociationsImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IQueryAssociationsImpl));
|
|
|
|
ei->ref=1;
|
|
|
|
ICOM_VTBL(ei) = &qavt;
|
|
|
|
|
|
|
|
TRACE("(%p)\n",ei);
|
|
|
|
return (IQueryAssociations *)ei;
|
|
|
|
}
|
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_QueryInterface
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnQueryInterface(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IQueryAssociationsImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvObj);
|
|
|
|
|
|
|
|
*ppvObj = NULL;
|
|
|
|
|
|
|
|
if(IsEqualIID(riid, &IID_IUnknown)) /*IUnknown*/
|
|
|
|
{
|
2002-05-31 23:06:46 +00:00
|
|
|
*ppvObj = This;
|
2000-04-28 20:22:33 +00:00
|
|
|
}
|
|
|
|
else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
|
|
|
|
{
|
|
|
|
*ppvObj = (IQueryAssociations*)This;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvObj)
|
|
|
|
{
|
2002-05-31 23:06:46 +00:00
|
|
|
IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
|
2000-04-28 20:22:33 +00:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n",ppvObj,*ppvObj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
TRACE("-- Interface: E_NOINTERFACE\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_AddRef
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IQueryAssociations_fnAddRef(IQueryAssociations * iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IQueryAssociationsImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(count=%lu)\n",This, This->ref );
|
|
|
|
|
|
|
|
return ++(This->ref);
|
|
|
|
}
|
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IQueryAssociationsImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
if (!--(This->ref))
|
2000-04-28 20:22:33 +00:00
|
|
|
{
|
|
|
|
TRACE(" destroying IExtractIcon(%p)\n",This);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return This->ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnInit(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
ASSOCF flags,
|
|
|
|
LPCWSTR pszAssoc,
|
|
|
|
HKEY hkProgid,
|
|
|
|
HWND hwnd)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetString(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
ASSOCF flags,
|
|
|
|
ASSOCSTR str,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
LPWSTR pszOut,
|
|
|
|
DWORD *pcchOut)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetKey(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
ASSOCF flags,
|
|
|
|
ASSOCKEY key,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
HKEY *phkeyOut)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetData(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
ASSOCF flags,
|
|
|
|
ASSOCDATA data,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
LPVOID pvOut,
|
|
|
|
DWORD *pcbOut)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
static HRESULT WINAPI IQueryAssociations_fnGetEnum(
|
|
|
|
IQueryAssociations * iface,
|
|
|
|
ASSOCF flags,
|
|
|
|
ASSOCENUM assocenum,
|
|
|
|
LPCWSTR pszExtra,
|
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2002-05-31 23:06:46 +00:00
|
|
|
static struct ICOM_VTABLE(IQueryAssociations) qavt =
|
|
|
|
{
|
2000-04-28 20:22:33 +00:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IQueryAssociations_fnQueryInterface,
|
|
|
|
IQueryAssociations_fnAddRef,
|
|
|
|
IQueryAssociations_fnRelease,
|
|
|
|
IQueryAssociations_fnInit,
|
2002-05-31 23:06:46 +00:00
|
|
|
IQueryAssociations_fnGetString,
|
2000-04-28 20:22:33 +00:00
|
|
|
IQueryAssociations_fnGetKey,
|
|
|
|
IQueryAssociations_fnGetData,
|
|
|
|
IQueryAssociations_fnGetEnum
|
|
|
|
};
|