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
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-11-22 18:26:23 +00:00
|
|
|
*/
|
2002-03-09 23:29:33 +00:00
|
|
|
|
2002-07-29 23:28:29 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
1998-11-22 18:26:23 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-09-05 23:08:26 +00:00
|
|
|
#include <stdarg.h>
|
2000-02-10 22:15:21 +00:00
|
|
|
#include <stdio.h>
|
2005-06-25 17:55:53 +00:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2002-03-09 23:29:33 +00:00
|
|
|
#include "wine/debug.h"
|
1998-11-22 18:26:23 +00:00
|
|
|
#include "winerror.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
1999-02-17 13:51:06 +00:00
|
|
|
#include "winreg.h"
|
2003-09-05 23:08:26 +00:00
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.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"
|
2005-06-25 17:55:53 +00:00
|
|
|
#include "pidl.h"
|
2002-12-13 23:45:36 +00:00
|
|
|
#include "wine/unicode.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
|
|
|
|
|
2005-07-03 12:03:35 +00:00
|
|
|
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
WCHAR szTemp[MAX_EXTENSION_LENGTH + 2];
|
|
|
|
|
2008-05-27 05:53:36 +00:00
|
|
|
TRACE("%s %p\n", debugstr_w(szExtension), szFileType);
|
2002-12-13 23:45:36 +00:00
|
|
|
|
|
|
|
/* added because we do not want to have double dots */
|
|
|
|
if (szExtension[0] == '.')
|
|
|
|
bPrependDot = 0;
|
|
|
|
|
|
|
|
if (bPrependDot)
|
|
|
|
szTemp[0] = '.';
|
|
|
|
|
|
|
|
lstrcpynW(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
|
|
|
|
2007-11-16 22:08:11 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey))
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RegQueryValueW(hkey, NULL, szFileType, &len))
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
|
|
|
TRACE("--UE;\n} %s\n", debugstr_w(szFileType));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-07-03 12:03:35 +00:00
|
|
|
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot)
|
2002-12-13 23:45:36 +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
|
|
|
|
2002-12-13 23:45:36 +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 */
|
2002-12-13 23:45:36 +00:00
|
|
|
if (szExtension[0] == '.')
|
|
|
|
bPrependDot = 0;
|
2001-10-23 00:25:15 +00:00
|
|
|
|
1999-08-15 14:24:49 +00:00
|
|
|
if (bPrependDot)
|
2002-12-13 23:45:36 +00:00
|
|
|
szTemp[0] = '.';
|
1999-08-15 14:24:49 +00:00
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
lstrcpynA(szTemp + (bPrependDot?1:0), szExtension, MAX_EXTENSION_LENGTH);
|
2002-05-31 23:06:46 +00:00
|
|
|
|
2007-11-16 22:08:11 +00:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey))
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
return FALSE;
|
1998-11-22 18:26:23 +00:00
|
|
|
}
|
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
if (RegQueryValueA(hkey, NULL, szFileType, &len))
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
1998-11-22 18:26:23 +00:00
|
|
|
return FALSE;
|
2002-05-31 23:06:46 +00:00
|
|
|
}
|
1998-11-22 18:26:23 +00:00
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
TRACE("--UE;\n} %s\n", szFileType);
|
1998-11-22 18:26:23 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-12-13 23:45:36 +00:00
|
|
|
|
2006-06-23 16:32:38 +00:00
|
|
|
static const WCHAR swShell[] = {'s','h','e','l','l','\\',0};
|
|
|
|
static const WCHAR swOpen[] = {'o','p','e','n',0};
|
|
|
|
static const WCHAR swCommand[] = {'\\','c','o','m','m','a','n','d',0};
|
|
|
|
|
|
|
|
BOOL HCR_GetDefaultVerbW( HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len )
|
|
|
|
{
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
LONG size;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
TRACE("%p %s %p\n", hkeyClass, debugstr_w(szVerb), szDest);
|
|
|
|
|
|
|
|
if (szVerb)
|
|
|
|
{
|
|
|
|
lstrcpynW(szDest, szVerb, len);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
size=len;
|
|
|
|
*szDest='\0';
|
|
|
|
if (!RegQueryValueW(hkeyClass, swShell, szDest, &size) && *szDest)
|
|
|
|
{
|
|
|
|
/* The MSDN says to first try the default verb */
|
|
|
|
lstrcpyW(sTemp, swShell);
|
|
|
|
lstrcatW(sTemp, szDest);
|
|
|
|
lstrcatW(sTemp, swCommand);
|
|
|
|
if (!RegOpenKeyExW(hkeyClass, sTemp, 0, 0, &hkey))
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
TRACE("default verb=%s\n", debugstr_w(szDest));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* then fallback to 'open' */
|
|
|
|
lstrcpyW(sTemp, swShell);
|
|
|
|
lstrcatW(sTemp, swOpen);
|
|
|
|
lstrcatW(sTemp, swCommand);
|
|
|
|
if (!RegOpenKeyExW(hkeyClass, sTemp, 0, 0, &hkey))
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
lstrcpynW(szDest, swOpen, len);
|
|
|
|
TRACE("default verb=open\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* and then just use the first verb on Windows >= 2000 */
|
|
|
|
if (!RegEnumKeyW(hkeyClass, 0, szDest, len) && *szDest)
|
|
|
|
{
|
|
|
|
TRACE("default verb=first verb=%s\n", debugstr_w(szDest));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("no default verb!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-12-13 23:45:36 +00:00
|
|
|
|
2004-01-16 23:06:25 +00:00
|
|
|
BOOL HCR_GetExecuteCommandW( HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len )
|
2003-12-10 00:39:31 +00:00
|
|
|
{
|
2006-06-23 16:32:38 +00:00
|
|
|
WCHAR sTempVerb[MAX_PATH];
|
|
|
|
BOOL ret;
|
2003-12-10 00:39:31 +00:00
|
|
|
|
|
|
|
TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest);
|
|
|
|
|
|
|
|
if (szClass)
|
2007-11-16 22:08:11 +00:00
|
|
|
RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ, &hkeyClass);
|
2006-06-23 16:32:38 +00:00
|
|
|
if (!hkeyClass)
|
|
|
|
return FALSE;
|
|
|
|
ret = FALSE;
|
|
|
|
|
2008-10-12 17:50:20 +00:00
|
|
|
if (HCR_GetDefaultVerbW(hkeyClass, szVerb, sTempVerb, sizeof(sTempVerb)/sizeof(sTempVerb[0])))
|
2006-06-23 16:32:38 +00:00
|
|
|
{
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
lstrcpyW(sTemp, swShell);
|
|
|
|
lstrcatW(sTemp, sTempVerb);
|
|
|
|
lstrcatW(sTemp, swCommand);
|
|
|
|
ret = (ERROR_SUCCESS == SHGetValueW(hkeyClass, sTemp, NULL, NULL, szDest, &len));
|
|
|
|
}
|
|
|
|
if (szClass)
|
|
|
|
RegCloseKey(hkeyClass);
|
2003-12-10 00:39:31 +00:00
|
|
|
|
|
|
|
TRACE("-- %s\n", debugstr_w(szDest) );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1998-12-14 17:33:00 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetDefaultIcon [internal]
|
|
|
|
*
|
|
|
|
* Gets the icon for a filetype
|
|
|
|
*/
|
2003-01-10 01:45:57 +00:00
|
|
|
static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
char xriid[50];
|
2006-10-15 10:27:34 +00:00
|
|
|
sprintf( xriid, "CLSID\\{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
|
2002-12-13 23:45:36 +00:00
|
|
|
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] );
|
|
|
|
|
|
|
|
TRACE("%s\n",xriid );
|
|
|
|
|
2003-01-10 01:45:57 +00:00
|
|
|
return !RegOpenKeyExA(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey);
|
2002-12-13 23:45:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, int* picon_idx)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
2006-01-11 11:33:24 +00:00
|
|
|
DWORD dwType;
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
WCHAR sNum[5];
|
2002-12-13 23:45:36 +00:00
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
|
|
|
|
{
|
2002-12-13 23:45:36 +00:00
|
|
|
if (dwType == REG_EXPAND_SZ)
|
2006-01-11 11:33:24 +00:00
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH);
|
|
|
|
lstrcpynW(szDest, sTemp, len);
|
|
|
|
}
|
|
|
|
if (ParseFieldW (szDest, 2, sNum, 5))
|
|
|
|
*picon_idx = atoiW(sNum);
|
2002-12-13 23:45:36 +00:00
|
|
|
else
|
2006-01-11 11:33:24 +00:00
|
|
|
*picon_idx=0; /* sometimes the icon number is missing */
|
|
|
|
ParseFieldW (szDest, 1, szDest, len);
|
2005-06-15 18:07:43 +00:00
|
|
|
PathUnquoteSpacesW(szDest);
|
2006-01-11 11:33:24 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2002-12-13 23:45:36 +00:00
|
|
|
}
|
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, int* picon_idx)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
DWORD dwType;
|
|
|
|
char sTemp[MAX_PATH];
|
|
|
|
char sNum[5];
|
|
|
|
|
2005-07-06 19:08:05 +00:00
|
|
|
if (!RegQueryValueExA(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
if (dwType == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
|
|
|
|
lstrcpynA(szDest, sTemp, len);
|
|
|
|
}
|
|
|
|
if (ParseFieldA (szDest, 2, sNum, 5))
|
2006-01-11 11:33:24 +00:00
|
|
|
*picon_idx=atoi(sNum);
|
2002-12-13 23:45:36 +00:00
|
|
|
else
|
2006-01-11 11:33:24 +00:00
|
|
|
*picon_idx=0; /* sometimes the icon number is missing */
|
2002-12-13 23:45:36 +00:00
|
|
|
ParseFieldA (szDest, 1, szDest, len);
|
2005-06-15 18:07:43 +00:00
|
|
|
PathUnquoteSpacesA(szDest);
|
2002-12-13 23:45:36 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
static const WCHAR swDefaultIcon[] = {'\\','D','e','f','a','u','l','t','I','c','o','n',0};
|
|
|
|
HKEY hkey;
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%s\n",debugstr_w(szClass) );
|
|
|
|
|
|
|
|
lstrcpynW(sTemp, szClass, MAX_PATH);
|
|
|
|
lstrcatW(sTemp, swDefaultIcon);
|
|
|
|
|
2007-11-16 22:08:11 +00:00
|
|
|
if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey))
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
2006-01-11 11:33:24 +00:00
|
|
|
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx);
|
2002-12-13 23:45:36 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2005-04-11 13:04:41 +00:00
|
|
|
|
|
|
|
if(ret)
|
2006-01-11 11:33:24 +00:00
|
|
|
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
|
2005-04-11 13:04:41 +00:00
|
|
|
else
|
|
|
|
TRACE("-- not found\n");
|
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx)
|
2000-06-24 12:56:08 +00:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
char sTemp[MAX_PATH];
|
|
|
|
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);
|
|
|
|
|
2007-11-16 22:08:11 +00:00
|
|
|
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hkey))
|
2000-06-24 12:56:08 +00:00
|
|
|
{
|
2006-01-11 11:33:24 +00:00
|
|
|
ret = HCR_RegGetDefaultIconA(hkey, szDest, len, picon_idx);
|
2000-06-24 12:56:08 +00:00
|
|
|
RegCloseKey(hkey);
|
1998-12-14 17:33:00 +00:00
|
|
|
}
|
2006-01-11 11:33:24 +00:00
|
|
|
TRACE("-- %s %i\n", szDest, *picon_idx);
|
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
|
|
|
|
2006-01-11 11:33:24 +00:00
|
|
|
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx)
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2003-01-10 01:45:57 +00:00
|
|
|
if (HCR_RegOpenClassIDKey(riid, &hkey))
|
2002-12-13 23:45:36 +00:00
|
|
|
{
|
2006-01-11 11:33:24 +00:00
|
|
|
ret = HCR_RegGetDefaultIconW(hkey, szDest, len, picon_idx);
|
2002-12-13 23:45:36 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2006-01-11 11:33:24 +00:00
|
|
|
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
|
2002-12-13 23:45:36 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-07-25 12:19:12 +00:00
|
|
|
/***************************************************************************************
|
|
|
|
* HCR_GetClassName [internal]
|
|
|
|
*
|
2004-07-23 23:02:09 +00:00
|
|
|
* Gets the name of a registered class
|
1999-07-25 12:19:12 +00:00
|
|
|
*/
|
2004-04-19 20:12:14 +00:00
|
|
|
static const WCHAR swEmpty[] = {0};
|
2002-12-13 23:45:36 +00:00
|
|
|
|
|
|
|
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
|
|
|
|
{
|
|
|
|
HKEY hkey;
|
1999-08-15 14:24:49 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
1999-07-25 12:19:12 +00:00
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
szDest[0] = 0;
|
|
|
|
if (HCR_RegOpenClassIDKey(riid, &hkey))
|
|
|
|
{
|
2006-02-14 09:41:29 +00:00
|
|
|
static const WCHAR wszLocalizedString[] =
|
|
|
|
{ 'L','o','c','a','l','i','z','e','d','S','t','r','i','n','g', 0 };
|
|
|
|
if (!RegLoadMUIStringW(hkey, wszLocalizedString, szDest, len, NULL, 0, NULL) ||
|
|
|
|
!RegQueryValueExW(hkey, swEmpty, 0, NULL, (LPBYTE)szDest, &len))
|
|
|
|
{
|
2002-12-13 23:45:36 +00:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret || !szDest[0])
|
|
|
|
{
|
|
|
|
if(IsEqualIID(riid, &CLSID_ShellDesktop))
|
|
|
|
{
|
|
|
|
if (LoadStringW(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &CLSID_MyComputer))
|
|
|
|
{
|
|
|
|
if(LoadStringW(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("-- %s\n", debugstr_w(szDest));
|
|
|
|
return ret;
|
|
|
|
}
|
1999-07-25 12:19:12 +00:00
|
|
|
|
2002-12-13 23:45:36 +00:00
|
|
|
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len)
|
|
|
|
{ HKEY hkey;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
1999-07-25 12:19:12 +00:00
|
|
|
|
2000-02-20 18:38:19 +00:00
|
|
|
szDest[0] = 0;
|
2002-12-13 23:45:36 +00:00
|
|
|
if (HCR_RegOpenClassIDKey(riid, &hkey))
|
1999-08-15 14:24:49 +00:00
|
|
|
{
|
2006-02-14 09:41:29 +00:00
|
|
|
if (!RegLoadMUIStringA(hkey,"LocalizedString",szDest,len,NULL,0,NULL) ||
|
|
|
|
!RegQueryValueExA(hkey,"",0,NULL,(LPBYTE)szDest,&len))
|
|
|
|
{
|
1999-08-15 14:24:49 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-06-25 17:55:53 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* HCR_GetFolderAttributes [Internal]
|
|
|
|
*
|
|
|
|
* Query the registry for a shell folders' attributes
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pidlFolder [I] A simple pidl of type PT_GUID.
|
|
|
|
* pdwAttributes [IO] In: Attributes to be queried, OUT: Resulting attributes.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE: Found information for the attributes in the registry
|
|
|
|
* FALSE: No attribute information found
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* If queried for an attribute, which is set in the CallForAttributes registry
|
|
|
|
* value, the function binds to the shellfolder objects and queries it.
|
|
|
|
*/
|
|
|
|
BOOL HCR_GetFolderAttributes(LPCITEMIDLIST pidlFolder, LPDWORD pdwAttributes)
|
|
|
|
{
|
|
|
|
HKEY hSFKey;
|
|
|
|
LPOLESTR pwszCLSID;
|
|
|
|
LONG lResult;
|
|
|
|
DWORD dwTemp, dwLen;
|
|
|
|
static const WCHAR wszAttributes[] = { 'A','t','t','r','i','b','u','t','e','s',0 };
|
|
|
|
static const WCHAR wszCallForAttributes[] = {
|
|
|
|
'C','a','l','l','F','o','r','A','t','t','r','i','b','u','t','e','s',0 };
|
|
|
|
WCHAR wszShellFolderKey[] = { 'C','L','S','I','D','\\','{','0','0','0','2','1','4','0','0','-',
|
|
|
|
'0','0','0','0','-','0','0','0','0','-','C','0','0','0','-','0','0','0','0','0','0','0',
|
|
|
|
'0','0','0','4','6','}','\\','S','h','e','l','l','F','o','l','d','e','r',0 };
|
|
|
|
|
|
|
|
TRACE("(pidlFolder=%p, pdwAttributes=%p)\n", pidlFolder, pdwAttributes);
|
|
|
|
|
|
|
|
if (!_ILIsPidlSimple(pidlFolder)) {
|
2008-03-18 21:34:51 +00:00
|
|
|
static int firstHit = 1;
|
|
|
|
if (firstHit) {
|
|
|
|
ERR("HCR_GetFolderAttributes should be called for simple PIDL's only!\n");
|
|
|
|
firstHit = 0;
|
|
|
|
}
|
2005-06-25 17:55:53 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_ILIsDesktop(pidlFolder)) {
|
|
|
|
if (FAILED(StringFromCLSID(_ILGetGUIDPointer(pidlFolder), &pwszCLSID))) return FALSE;
|
|
|
|
memcpy(&wszShellFolderKey[6], pwszCLSID, 38 * sizeof(WCHAR));
|
|
|
|
CoTaskMemFree(pwszCLSID);
|
|
|
|
}
|
|
|
|
|
|
|
|
lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszShellFolderKey, 0, KEY_READ, &hSFKey);
|
|
|
|
if (lResult != ERROR_SUCCESS) return FALSE;
|
|
|
|
|
|
|
|
dwLen = sizeof(DWORD);
|
|
|
|
lResult = RegQueryValueExW(hSFKey, wszCallForAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen);
|
|
|
|
if ((lResult == ERROR_SUCCESS) && (dwTemp & *pdwAttributes)) {
|
|
|
|
LPSHELLFOLDER psfDesktop, psfFolder;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
RegCloseKey(hSFKey);
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
hr = IShellFolder_BindToObject(psfDesktop, pidlFolder, NULL, &IID_IShellFolder,
|
|
|
|
(LPVOID*)&psfFolder);
|
|
|
|
if (SUCCEEDED(hr)) {
|
|
|
|
hr = IShellFolder_GetAttributesOf(psfFolder, 0, NULL, pdwAttributes);
|
2005-07-18 13:13:05 +00:00
|
|
|
IShellFolder_Release(psfFolder);
|
2005-06-25 17:55:53 +00:00
|
|
|
}
|
2005-07-18 13:13:05 +00:00
|
|
|
IShellFolder_Release(psfDesktop);
|
2005-06-25 17:55:53 +00:00
|
|
|
}
|
|
|
|
if (FAILED(hr)) return FALSE;
|
|
|
|
} else {
|
|
|
|
lResult = RegQueryValueExW(hSFKey, wszAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen);
|
|
|
|
RegCloseKey(hSFKey);
|
|
|
|
if (lResult == ERROR_SUCCESS) {
|
|
|
|
*pdwAttributes &= dwTemp;
|
|
|
|
} else {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-07 18:18:14 +00:00
|
|
|
TRACE("-- *pdwAttributes == 0x%08x\n", *pdwAttributes);
|
2005-06-25 17:55:53 +00:00
|
|
|
|
|
|
|
return TRUE;
|
1998-12-14 17:33:00 +00:00
|
|
|
}
|