1998-11-22 19:26:23 +01:00
|
|
|
/*
|
|
|
|
* file type mapping
|
|
|
|
* (HKEY_CLASSES_ROOT - Stuff)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-02-10 23:15:21 +01:00
|
|
|
#include <stdio.h>
|
1999-06-12 17:45:58 +02:00
|
|
|
#include "debugtools.h"
|
1998-11-22 19:26:23 +01:00
|
|
|
#include "winerror.h"
|
1999-02-17 14:51:06 +01:00
|
|
|
#include "winreg.h"
|
1998-11-22 19:26:23 +01:00
|
|
|
|
2000-04-28 22:22:33 +02:00
|
|
|
#include "wine/obj_queryassociations.h"
|
1999-01-23 15:12:48 +01:00
|
|
|
#include "shlobj.h"
|
1998-11-22 19:26:23 +01:00
|
|
|
#include "shell32_main.h"
|
1999-08-15 16:24:49 +02:00
|
|
|
#include "shlguid.h"
|
|
|
|
#include "shresdef.h"
|
1998-11-22 19:26:23 +01:00
|
|
|
|
2000-02-10 23:15:21 +01:00
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-07-25 14:19:12 +02:00
|
|
|
#define MAX_EXTENSION_LENGTH 20
|
|
|
|
|
1999-08-15 16:24:49 +02:00
|
|
|
BOOL HCR_MapTypeToValue ( LPCSTR szExtension, LPSTR szFileType, DWORD len, BOOL bPrependDot)
|
1998-11-22 19:26:23 +01:00
|
|
|
{ HKEY hkey;
|
1999-07-25 14:19:12 +02:00
|
|
|
char szTemp[MAX_EXTENSION_LENGTH + 2];
|
1998-11-22 19:26:23 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("%s %p\n",szExtension, szFileType );
|
1998-12-11 11:58:48 +01:00
|
|
|
|
1999-08-15 16:24:49 +02:00
|
|
|
if (bPrependDot)
|
|
|
|
strcpy(szTemp, ".");
|
|
|
|
|
|
|
|
lstrcpynA(szTemp+((bPrependDot)?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
1999-07-25 14:19:12 +02:00
|
|
|
|
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT,szTemp,0,0x02000000,&hkey))
|
1998-11-22 19:26:23 +01:00
|
|
|
{ return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (RegQueryValueA(hkey,NULL,szFileType,&len))
|
1998-11-22 19:26:23 +01:00
|
|
|
{ RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- %s\n", szFileType );
|
1998-11-22 19:26:23 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL HCR_GetExecuteCommand ( LPCSTR szClass, LPCSTR szVerb, LPSTR szDest, DWORD len )
|
1998-12-11 11:58:48 +01:00
|
|
|
{ HKEY hkey;
|
|
|
|
char sTemp[256];
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("%s %s\n",szClass, szVerb );
|
1998-12-11 11:58:48 +01:00
|
|
|
|
|
|
|
sprintf(sTemp, "%s\\shell\\%s\\command",szClass, szVerb);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
1998-12-11 11:58:48 +01:00
|
|
|
{ return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (RegQueryValueA(hkey,NULL,szDest,&len))
|
1998-12-11 11:58:48 +01:00
|
|
|
{ RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- %s\n", szDest );
|
1998-12-11 11:58:48 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
1998-12-14 18:33:00 +01:00
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetDefaultIcon [internal]
|
|
|
|
*
|
|
|
|
* Gets the icon for a filetype
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL HCR_GetDefaultIcon (LPCSTR szClass, LPSTR szDest, DWORD len, LPDWORD dwNr)
|
1998-12-14 18:33:00 +01:00
|
|
|
{ HKEY hkey;
|
|
|
|
char sTemp[256];
|
|
|
|
char sNum[5];
|
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("%s\n",szClass );
|
1998-12-14 18:33:00 +01:00
|
|
|
|
|
|
|
sprintf(sTemp, "%s\\DefaultIcon",szClass);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT,sTemp,0,0x02000000,&hkey))
|
1998-12-14 18:33:00 +01:00
|
|
|
{ return FALSE;
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (RegQueryValueA(hkey,NULL,szDest,&len))
|
1998-12-14 18:33:00 +01:00
|
|
|
{ RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
if (ParseFieldA (szDest, 2, sNum, 5))
|
1998-12-14 18:33:00 +01:00
|
|
|
{ *dwNr=atoi(sNum);
|
|
|
|
}
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
ParseFieldA (szDest, 1, szDest, len);
|
1998-12-14 18:33:00 +01:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("-- %s %li\n", szDest, *dwNr );
|
1998-12-14 18:33:00 +01:00
|
|
|
|
|
|
|
return TRUE;
|
1999-07-25 14:19:12 +02:00
|
|
|
}
|
1998-12-14 18:33:00 +01:00
|
|
|
|
1999-07-25 14:19:12 +02: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 16:24:49 +02:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
1999-07-25 14:19:12 +02:00
|
|
|
|
|
|
|
strcpy(xriid,"CLSID\\");
|
|
|
|
WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|
|
|
|
|
|
|
TRACE("%s\n",xriid );
|
|
|
|
|
2000-02-20 19:38:19 +01:00
|
|
|
szDest[0] = 0;
|
1999-08-15 16:24:49 +02: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 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
1999-08-15 16:24:49 +02:00
|
|
|
if (!ret || !szDest[0])
|
|
|
|
{
|
|
|
|
if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
|
|
|
{
|
2000-02-20 19:38:19 +01:00
|
|
|
if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
|
|
|
|
ret = TRUE;
|
1999-08-15 16:24:49 +02:00
|
|
|
}
|
1999-11-23 23:31:18 +01:00
|
|
|
else if (IsEqualIID(riid, &CLSID_MyComputer))
|
1999-08-15 16:24:49 +02:00
|
|
|
{
|
2000-02-20 19:38:19 +01:00
|
|
|
if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
|
|
|
|
ret = TRUE;
|
1999-08-15 16:24:49 +02:00
|
|
|
}
|
|
|
|
}
|
1999-07-25 14:19:12 +02:00
|
|
|
|
|
|
|
TRACE("-- %s\n", szDest);
|
|
|
|
|
1999-08-15 16:24:49 +02:00
|
|
|
return ret;
|
1999-07-25 14:19:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetFolderAttributes [internal]
|
|
|
|
*
|
|
|
|
* gets the folder attributes of a class
|
1999-11-23 23:31:18 +01:00
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* verify the defaultvalue for *szDest
|
1999-07-25 14:19:12 +02:00
|
|
|
*/
|
|
|
|
BOOL HCR_GetFolderAttributes (REFIID riid, LPDWORD szDest)
|
|
|
|
{ HKEY hkey;
|
|
|
|
char xriid[60];
|
|
|
|
DWORD attributes;
|
|
|
|
DWORD len = 4;
|
|
|
|
|
|
|
|
strcpy(xriid,"CLSID\\");
|
|
|
|
WINE_StringFromCLSID(riid,&xriid[strlen(xriid)]);
|
|
|
|
TRACE("%s\n",xriid );
|
|
|
|
|
1999-11-23 23:31:18 +01:00
|
|
|
if (!szDest) return FALSE;
|
|
|
|
*szDest = SFGAO_FOLDER|SFGAO_FILESYSTEM;
|
|
|
|
|
1999-07-25 14:19:12 +02: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 16:24:49 +02:00
|
|
|
}
|
1999-07-25 14:19:12 +02:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
TRACE("-- 0x%08lx\n", attributes);
|
|
|
|
|
|
|
|
*szDest = attributes;
|
|
|
|
|
|
|
|
return TRUE;
|
1998-12-14 18:33:00 +01:00
|
|
|
}
|
1998-11-22 19:26:23 +01:00
|
|
|
|
2000-04-28 22:22:33 +02:00
|
|
|
typedef struct
|
|
|
|
{ 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);
|
|
|
|
shell32_ObjCount++;
|
|
|
|
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*/
|
|
|
|
{
|
|
|
|
*ppvObj = This;
|
|
|
|
}
|
|
|
|
else if(IsEqualIID(riid, &IID_IQueryAssociations)) /*IExtractIcon*/
|
|
|
|
{
|
|
|
|
*ppvObj = (IQueryAssociations*)This;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvObj)
|
|
|
|
{
|
|
|
|
IQueryAssociations_AddRef((IQueryAssociations*) *ppvObj);
|
|
|
|
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 );
|
|
|
|
|
|
|
|
shell32_ObjCount++;
|
|
|
|
|
|
|
|
return ++(This->ref);
|
|
|
|
}
|
|
|
|
/**************************************************************************
|
|
|
|
* IQueryAssociations_Release
|
|
|
|
*/
|
|
|
|
static ULONG WINAPI IQueryAssociations_fnRelease(IQueryAssociations * iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(IQueryAssociationsImpl,iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n",This);
|
|
|
|
|
|
|
|
shell32_ObjCount--;
|
|
|
|
|
|
|
|
if (!--(This->ref))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ICOM_VTABLE(IQueryAssociations) qavt =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IQueryAssociations_fnQueryInterface,
|
|
|
|
IQueryAssociations_fnAddRef,
|
|
|
|
IQueryAssociations_fnRelease,
|
|
|
|
IQueryAssociations_fnInit,
|
|
|
|
IQueryAssociations_fnGetString,
|
|
|
|
IQueryAssociations_fnGetKey,
|
|
|
|
IQueryAssociations_fnGetData,
|
|
|
|
IQueryAssociations_fnGetEnum
|
|
|
|
};
|