2011-05-15 15:55:49 +00:00
|
|
|
/*
|
2011-09-07 23:21:02 +00:00
|
|
|
* file type mapping
|
|
|
|
* (HKEY_CLASSES_ROOT - Stuff)
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Copyright 1998, 1999, 2000 Juergen Schmied
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
#include "precomp.h"
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
#define MAX_EXTENSION_LENGTH 20
|
|
|
|
|
|
|
|
BOOL HCR_MapTypeToValueW(LPCWSTR szExtension, LPWSTR szFileType, LONG len, BOOL bPrependDot)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
HKEY hkey;
|
|
|
|
WCHAR szTemp[MAX_EXTENSION_LENGTH + 2];
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("%s %p\n", debugstr_w(szExtension), debugstr_w(szFileType));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/* added because we do not want to have double dots */
|
|
|
|
if (szExtension[0] == '.')
|
|
|
|
bPrependDot = 0;
|
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (bPrependDot)
|
2011-12-18 21:54:04 +00:00
|
|
|
szTemp[0] = '.';
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
lstrcpynW(szTemp + (bPrependDot ? 1 : 0), szExtension, MAX_EXTENSION_LENGTH);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (RegQueryValueW(hkey, NULL, szFileType, &len) != ERROR_SUCCESS)
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
RegCloseKey(hkey);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("--UE;\n} %s\n", debugstr_w(szFileType));
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
return TRUE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL HCR_MapTypeToValueA(LPCSTR szExtension, LPSTR szFileType, LONG len, BOOL bPrependDot)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
HKEY hkey;
|
|
|
|
char szTemp[MAX_EXTENSION_LENGTH + 2];
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("%s %p\n", szExtension, szFileType);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
/* added because we do not want to have double dots */
|
|
|
|
if (szExtension[0] == '.')
|
|
|
|
bPrependDot = 0;
|
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (bPrependDot)
|
2011-12-18 21:54:04 +00:00
|
|
|
szTemp[0] = '.';
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
lstrcpynA(szTemp + (bPrependDot ? 1 : 0), szExtension, MAX_EXTENSION_LENGTH);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (RegOpenKeyExA(HKEY_CLASSES_ROOT, szTemp, 0, KEY_READ, &hkey))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
return FALSE;
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (RegLoadMUIStringA(hkey, "FriendlyTypeName", szFileType, len, NULL, 0, NULL) == ERROR_SUCCESS)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return TRUE;
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (RegQueryValueA(hkey, NULL, szFileType, &len))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return FALSE;
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
RegCloseKey(hkey);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("--UE;\n} %s\n", szFileType);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
return TRUE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
static const WCHAR swShell[] = L"shell\\";
|
|
|
|
static const WCHAR swOpen[] = L"open";
|
|
|
|
static const WCHAR swCommand[] = L"\\command";
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
BOOL HCR_GetDefaultVerbW(HKEY hkeyClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
LONG size;
|
|
|
|
HKEY hkey;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("%p %s %p\n", hkeyClass, debugstr_w(szVerb), szDest);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (szVerb)
|
|
|
|
{
|
|
|
|
lstrcpynW(szDest, szVerb, len);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
size = len;
|
|
|
|
*szDest = '\0';
|
|
|
|
if (RegQueryValueW(hkeyClass, L"shell", szDest, &size) == ERROR_SUCCESS && *szDest)
|
|
|
|
{
|
|
|
|
/* The MSDN says to first try the default verb */
|
2011-05-15 15:55:49 +00:00
|
|
|
wcscpy(sTemp, swShell);
|
2011-12-18 21:54:04 +00:00
|
|
|
wcscat(sTemp, szDest);
|
2011-05-15 15:55:49 +00:00
|
|
|
wcscat(sTemp, swCommand);
|
2011-12-18 21:54:04 +00:00
|
|
|
if (RegOpenKeyExW(hkeyClass, sTemp, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("default verb=%s\n", debugstr_w(szDest));
|
2011-05-15 15:55:49 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* then fallback to 'open' */
|
|
|
|
wcscpy(sTemp, swShell);
|
|
|
|
wcscat(sTemp, swOpen);
|
|
|
|
wcscat(sTemp, swCommand);
|
|
|
|
if (RegOpenKeyExW(hkeyClass, sTemp, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
lstrcpynW(szDest, swOpen, len);
|
|
|
|
TRACE("default verb=open\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
/* and then just use the first verb on Windows >= 2000 */
|
|
|
|
if (RegOpenKeyExW(hkeyClass, L"shell", 0, KEY_READ, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (RegEnumKeyW(hkey, 0, szDest, len) == ERROR_SUCCESS && *szDest)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("default verb=first verb=%s\n", debugstr_w(szDest));
|
2011-05-15 15:55:49 +00:00
|
|
|
RegCloseKey(hkey);
|
2011-12-18 21:54:04 +00:00
|
|
|
return TRUE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("no default verb!\n");
|
|
|
|
return FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
BOOL HCR_GetExecuteCommandW(HKEY hkeyClass, LPCWSTR szClass, LPCWSTR szVerb, LPWSTR szDest, DWORD len)
|
2011-05-15 15:55:49 +00:00
|
|
|
{
|
2011-09-07 23:21:02 +00:00
|
|
|
WCHAR sTempVerb[MAX_PATH];
|
|
|
|
BOOL ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("%p %s %s %p\n", hkeyClass, debugstr_w(szClass), debugstr_w(szVerb), szDest);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (szClass)
|
2011-12-18 21:54:04 +00:00
|
|
|
RegOpenKeyExW(HKEY_CLASSES_ROOT, szClass, 0, KEY_READ, &hkeyClass);
|
|
|
|
if (!hkeyClass)
|
|
|
|
return FALSE;
|
|
|
|
ret = FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (HCR_GetDefaultVerbW(hkeyClass, szVerb, sTempVerb, sizeof(sTempVerb)))
|
|
|
|
{
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
wcscpy(sTemp, swShell);
|
|
|
|
wcscat(sTemp, sTempVerb);
|
|
|
|
wcscat(sTemp, swCommand);
|
|
|
|
ret = (ERROR_SUCCESS == SHGetValueW(hkeyClass, sTemp, NULL, NULL, szDest, &len));
|
|
|
|
}
|
|
|
|
if (szClass)
|
|
|
|
RegCloseKey(hkeyClass);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("-- %s\n", debugstr_w(szDest));
|
2011-09-07 23:21:02 +00:00
|
|
|
return ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************************
|
2011-09-07 23:21:02 +00:00
|
|
|
* HCR_GetDefaultIcon [internal]
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Gets the icon for a filetype
|
|
|
|
*/
|
|
|
|
static BOOL HCR_RegOpenClassIDKey(REFIID riid, HKEY *hkey)
|
|
|
|
{
|
2011-09-07 23:21:02 +00:00
|
|
|
WCHAR xriid[50];
|
2011-12-18 21:54:04 +00:00
|
|
|
swprintf(xriid, L"CLSID\\{%08x-%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] );
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("%S\n", xriid);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
return (RegOpenKeyExW(HKEY_CLASSES_ROOT, xriid, 0, KEY_READ, hkey) == ERROR_SUCCESS);
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL HCR_RegGetDefaultIconW(HKEY hkey, LPWSTR szDest, DWORD len, int* picon_idx)
|
|
|
|
{
|
|
|
|
DWORD dwType;
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
WCHAR sNum[7];
|
|
|
|
|
|
|
|
if (!RegQueryValueExW(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
if (dwType == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsW(szDest, sTemp, MAX_PATH);
|
|
|
|
lstrcpynW(szDest, sTemp, len);
|
|
|
|
}
|
|
|
|
if (ParseFieldW (szDest, 2, sNum, _countof(sNum)))
|
|
|
|
*picon_idx = atoiW(sNum);
|
|
|
|
else
|
|
|
|
*picon_idx = 0; /* sometimes the icon number is missing */
|
|
|
|
ParseFieldW (szDest, 1, szDest, len);
|
|
|
|
PathUnquoteSpacesW(szDest);
|
|
|
|
return TRUE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL HCR_RegGetDefaultIconA(HKEY hkey, LPSTR szDest, DWORD len, int* picon_idx)
|
|
|
|
{
|
2011-09-07 23:21:02 +00:00
|
|
|
DWORD dwType;
|
|
|
|
char sTemp[MAX_PATH];
|
|
|
|
char sNum[5];
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
if (!RegQueryValueExA(hkey, NULL, 0, &dwType, (LPBYTE)szDest, &len))
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
if (dwType == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
ExpandEnvironmentStringsA(szDest, sTemp, MAX_PATH);
|
|
|
|
lstrcpynA(szDest, sTemp, len);
|
|
|
|
}
|
|
|
|
if (ParseFieldA (szDest, 2, sNum, 5))
|
|
|
|
*picon_idx = atoi(sNum);
|
|
|
|
else
|
|
|
|
*picon_idx = 0; /* sometimes the icon number is missing */
|
|
|
|
ParseFieldA (szDest, 1, szDest, len);
|
|
|
|
PathUnquoteSpacesA(szDest);
|
|
|
|
return TRUE;
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL HCR_GetDefaultIconW(LPCWSTR szClass, LPWSTR szDest, DWORD len, int* picon_idx)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
static const WCHAR swDefaultIcon[] = L"\\DefaultIcon";
|
|
|
|
HKEY hKey;
|
|
|
|
WCHAR sTemp[MAX_PATH];
|
|
|
|
BOOL ret = FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("%s\n", debugstr_w(szClass) );
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
lstrcpynW(sTemp, szClass, MAX_PATH);
|
|
|
|
wcscat(sTemp, swDefaultIcon);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!RegOpenKeyExW(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hKey))
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
ret = HCR_RegGetDefaultIconW(hKey, szDest, len, picon_idx);
|
|
|
|
RegCloseKey(hKey);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if(ret)
|
|
|
|
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
|
|
|
|
else
|
|
|
|
TRACE("-- not found\n");
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
return ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL HCR_GetDefaultIconA(LPCSTR szClass, LPSTR szDest, DWORD len, int* picon_idx)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
HKEY hKey;
|
|
|
|
char sTemp[MAX_PATH];
|
|
|
|
BOOL ret = FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
TRACE("%s\n", szClass );
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
sprintf(sTemp, "%s\\DefaultIcon", szClass);
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!RegOpenKeyExA(HKEY_CLASSES_ROOT, sTemp, 0, KEY_READ, &hKey))
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
ret = HCR_RegGetDefaultIconA(hKey, szDest, len, picon_idx);
|
|
|
|
RegCloseKey(hKey);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
TRACE("-- %s %i\n", szDest, *picon_idx);
|
|
|
|
return ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL HCR_GetDefaultIconFromGUIDW(REFIID riid, LPWSTR szDest, DWORD len, int* picon_idx)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
HKEY hKey;
|
|
|
|
BOOL ret = FALSE;
|
2011-09-07 23:21:02 +00:00
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (HCR_RegOpenClassIDKey(riid, &hKey))
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
ret = HCR_RegGetDefaultIconW(hKey, szDest, len, picon_idx);
|
|
|
|
RegCloseKey(hKey);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
TRACE("-- %s %i\n", debugstr_w(szDest), *picon_idx);
|
|
|
|
return ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************************************************
|
2011-09-07 23:21:02 +00:00
|
|
|
* HCR_GetClassName [internal]
|
2011-05-15 15:55:49 +00:00
|
|
|
*
|
|
|
|
* Gets the name of a registered class
|
|
|
|
*/
|
|
|
|
static const WCHAR swEmpty[] = {0};
|
|
|
|
|
|
|
|
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
HKEY hKey;
|
2011-09-07 23:21:02 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
|
|
|
WCHAR szName[100];
|
|
|
|
LPOLESTR pStr;
|
|
|
|
|
|
|
|
szDest[0] = 0;
|
|
|
|
|
|
|
|
if (StringFromCLSID(riid, &pStr) == S_OK)
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
DWORD dwLen = buflen * sizeof(WCHAR);
|
|
|
|
swprintf(szName, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\%s", pStr);
|
|
|
|
if (RegGetValueW(HKEY_CURRENT_USER, szName, NULL, RRF_RT_REG_SZ, NULL, (PVOID)szDest, &dwLen) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
CoTaskMemFree(pStr);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!ret && HCR_RegOpenClassIDKey(riid, &hKey))
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
static const WCHAR wszLocalizedString[] = L"LocalizedString";
|
|
|
|
|
|
|
|
if (RegLoadMUIStringW(hKey, wszLocalizedString, szDest, len, NULL, 0, NULL) == ERROR_SUCCESS ||
|
|
|
|
RegQueryValueExW(hKey, swEmpty, 0, NULL, (LPBYTE)szDest, &len) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret || !szDest[0])
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, CLSID_MyDocuments))
|
|
|
|
{
|
|
|
|
if(LoadStringW(shell32_hInstance, IDS_PERSONAL, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, CLSID_RecycleBin))
|
|
|
|
{
|
|
|
|
if(LoadStringW(shell32_hInstance, IDS_RECYCLEBIN_FOLDER_NAME, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, CLSID_ControlPanel))
|
|
|
|
{
|
|
|
|
if(LoadStringW(shell32_hInstance, IDS_CONTROLPANEL, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, CLSID_AdminFolderShortcut))
|
|
|
|
{
|
|
|
|
if(LoadStringW(shell32_hInstance, IDS_ADMINISTRATIVETOOLS, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
2011-12-17 22:48:16 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
TRACE("-- %s\n", debugstr_w(szDest));
|
|
|
|
return ret;
|
2011-05-15 15:55:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL HCR_GetClassNameA(REFIID riid, LPSTR szDest, DWORD len)
|
2011-12-18 21:54:04 +00:00
|
|
|
{ HKEY hKey;
|
2011-09-07 23:21:02 +00:00
|
|
|
BOOL ret = FALSE;
|
|
|
|
DWORD buflen = len;
|
2011-05-15 15:55:49 +00:00
|
|
|
|
2011-09-07 23:21:02 +00:00
|
|
|
szDest[0] = 0;
|
2011-12-18 21:54:04 +00:00
|
|
|
if (HCR_RegOpenClassIDKey(riid, &hKey))
|
2011-09-07 23:21:02 +00:00
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!RegLoadMUIStringA(hKey, "LocalizedString", szDest, len, NULL, 0, NULL) ||
|
|
|
|
!RegQueryValueExA(hKey, "", 0, NULL, (LPBYTE)szDest, &len))
|
|
|
|
{
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret || !szDest[0])
|
|
|
|
{
|
2011-12-18 21:54:04 +00:00
|
|
|
if(IsEqualIID(riid, CLSID_ShellDesktop))
|
|
|
|
{
|
|
|
|
if (LoadStringA(shell32_hInstance, IDS_DESKTOP, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, CLSID_MyComputer))
|
|
|
|
{
|
|
|
|
if(LoadStringA(shell32_hInstance, IDS_MYCOMPUTER, szDest, buflen))
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
2011-09-07 23:21:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("-- %s\n", szDest);
|
|
|
|
|
|
|
|
return ret;
|
2011-05-15 15:55:49 +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;
|
2011-12-18 21:54:04 +00:00
|
|
|
static const WCHAR wszAttributes[] = L"Attributes";
|
|
|
|
static const WCHAR wszCallForAttributes[] = L"CallForAttributes";
|
|
|
|
WCHAR wszShellFolderKey[] = L"CLSID\\{00021400-0000-0000-C000-000000000046}\\ShellFolder";
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
TRACE("(pidlFolder=%p, pdwAttributes=%p)\n", pidlFolder, pdwAttributes);
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!_ILIsPidlSimple(pidlFolder))
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
ERR("should be called for simple PIDL's only!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-18 21:54:04 +00:00
|
|
|
if (!_ILIsDesktop(pidlFolder))
|
|
|
|
{
|
|
|
|
if (FAILED(StringFromCLSID(*_ILGetGUIDPointer(pidlFolder), &pwszCLSID)))
|
|
|
|
return FALSE;
|
2011-05-15 15:55:49 +00:00
|
|
|
memcpy(&wszShellFolderKey[6], pwszCLSID, 38 * sizeof(WCHAR));
|
|
|
|
CoTaskMemFree(pwszCLSID);
|
|
|
|
}
|
|
|
|
|
|
|
|
lResult = RegOpenKeyExW(HKEY_CLASSES_ROOT, wszShellFolderKey, 0, KEY_READ, &hSFKey);
|
2011-12-18 21:54:04 +00:00
|
|
|
if (lResult != ERROR_SUCCESS)
|
2011-12-18 22:56:13 +00:00
|
|
|
{
|
|
|
|
ERR("Cannot open key: %ls\n", wszShellFolderKey);
|
2011-12-18 21:54:04 +00:00
|
|
|
return FALSE;
|
2011-12-18 22:56:13 +00:00
|
|
|
}
|
2011-05-15 15:55:49 +00:00
|
|
|
|
|
|
|
dwLen = sizeof(DWORD);
|
|
|
|
lResult = RegQueryValueExW(hSFKey, wszCallForAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen);
|
2011-12-18 21:54:04 +00:00
|
|
|
if ((lResult == ERROR_SUCCESS) && (dwTemp & *pdwAttributes))
|
|
|
|
{
|
|
|
|
CComPtr<IShellFolder> psfDesktop;
|
|
|
|
CComPtr<IShellFolder> psfFolder;
|
2011-05-15 15:55:49 +00:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
RegCloseKey(hSFKey);
|
|
|
|
hr = SHGetDesktopFolder(&psfDesktop);
|
2011-12-18 21:54:04 +00:00
|
|
|
if (SUCCEEDED(hr))
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
hr = psfDesktop->BindToObject(pidlFolder, NULL, IID_IShellFolder,
|
2011-12-18 21:54:04 +00:00
|
|
|
(LPVOID*)&psfFolder);
|
|
|
|
if (SUCCEEDED(hr))
|
2011-05-15 15:55:49 +00:00
|
|
|
hr = psfFolder->GetAttributesOf(0, NULL, pdwAttributes);
|
|
|
|
}
|
2011-12-18 21:54:04 +00:00
|
|
|
if (FAILED(hr))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-15 15:55:49 +00:00
|
|
|
lResult = RegQueryValueExW(hSFKey, wszAttributes, 0, NULL, (LPBYTE)&dwTemp, &dwLen);
|
|
|
|
RegCloseKey(hSFKey);
|
2011-12-18 21:54:04 +00:00
|
|
|
if (lResult == ERROR_SUCCESS)
|
2011-05-15 15:55:49 +00:00
|
|
|
*pdwAttributes &= dwTemp;
|
2011-12-18 21:54:04 +00:00
|
|
|
else
|
2011-05-15 15:55:49 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("-- *pdwAttributes == 0x%08x\n", *pdwAttributes);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|