Skip to content

Commit

Permalink
[SHELL32] Use wide char string literals.
Browse files Browse the repository at this point in the history
Import parts of Wine commit b215536852dc5a132108db92c90a41c70b738e50
shell32: Use wide char string literals.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
  • Loading branch information
HBelusca committed Jan 9, 2022
1 parent 59b3545 commit 83be315
Show file tree
Hide file tree
Showing 21 changed files with 337 additions and 582 deletions.
6 changes: 1 addition & 5 deletions dll/win32/shell32/CDefView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@

WINE_DEFAULT_DEBUG_CHANNEL(shell);

#undef SV_CLASS_NAME

static const WCHAR SV_CLASS_NAME[] = {'S', 'H', 'E', 'L', 'L', 'D', 'L', 'L', '_', 'D', 'e', 'f', 'V', 'i', 'e', 'w', 0};

typedef struct
{
BOOL bIsAscending;
Expand Down Expand Up @@ -298,7 +294,7 @@ class CDefView :
{
{ sizeof(WNDCLASSEX), CS_PARENTDC, StartWindowProc,
0, 0, NULL, NULL,
LoadCursor(NULL, IDC_ARROW), NULL, NULL, SV_CLASS_NAME, NULL
LoadCursor(NULL, IDC_ARROW), NULL, NULL, L"SHELLDLL_DefView", NULL
},
NULL, NULL, IDC_ARROW, TRUE, 0, _T("")
};
Expand Down
45 changes: 15 additions & 30 deletions dll/win32/shell32/CQueryAssociations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::Init(
HKEY hkeyProgid,
HWND hWnd)
{
static const WCHAR szProgID[] = L"ProgID";

TRACE("(%p)->(%d,%s,%p,%p)\n", this,
cfFlags,
debugstr_w(pszAssoc),
Expand Down Expand Up @@ -128,11 +126,7 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::Init(
{
HKEY progIdKey;
/* for a clsid, the progid is the default value of the ProgID subkey */
ret = RegOpenKeyExW(this->hkeySource,
szProgID,
0,
KEY_READ,
&progIdKey);
ret = RegOpenKeyExW(this->hkeySource, L"ProgID", 0, KEY_READ, &progIdKey);
if (ret != ERROR_SUCCESS)
return S_OK;
hr = this->GetValue(progIdKey, NULL, (void**)&progId, NULL);
Expand Down Expand Up @@ -274,8 +268,6 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
DWORD size, retval = 0;
UINT flen;
WCHAR *bufW;
static const WCHAR translationW[] = L"\\VarFileInfo\\Translation";
static const WCHAR fileDescFmtW[] = L"\\StringFileInfo\\%04x%04x\\FileDescription";
WCHAR fileDescW[41];

hr = this->GetExecutable(pszExtra, path, MAX_PATH, &len);
Expand All @@ -297,13 +289,14 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
{
goto get_friendly_name_fail;
}
if (VerQueryValueW(verinfoW, translationW, (LPVOID *)&bufW, &flen))
if (VerQueryValueW(verinfoW, L"\\VarFileInfo\\Translation", (LPVOID *)&bufW, &flen))
{
UINT i;
DWORD *langCodeDesc = (DWORD *)bufW;
for (i = 0; i < flen / sizeof(DWORD); i++)
{
sprintfW(fileDescW, fileDescFmtW, LOWORD(langCodeDesc[i]), HIWORD(langCodeDesc[i]));
sprintfW(fileDescW, L"\\StringFileInfo\\%04x%04x\\FileDescription",
LOWORD(langCodeDesc[i]), HIWORD(langCodeDesc[i]));
if (VerQueryValueW(verinfoW, fileDescW, (LPVOID *)&bufW, &flen))
{
/* Does strlenW(bufW) == 0 mean we use the filename? */
Expand All @@ -325,18 +318,16 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
}
case ASSOCSTR_CONTENTTYPE:
{
static const WCHAR Content_TypeW[] = L"Content Type";

DWORD size = 0;
DWORD ret = RegGetValueW(this->hkeySource, NULL, Content_TypeW, RRF_RT_REG_SZ, NULL, NULL, &size);
DWORD ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, NULL, &size);
if (ret != ERROR_SUCCESS)
{
return HRESULT_FROM_WIN32(ret);
}
WCHAR *contentType = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
if (contentType != NULL)
{
ret = RegGetValueW(this->hkeySource, NULL, Content_TypeW, RRF_RT_REG_SZ, NULL, contentType, &size);
ret = RegGetValueW(this->hkeySource, NULL, L"Content Type", RRF_RT_REG_SZ, NULL, contentType, &size);
if (ret == ERROR_SUCCESS)
{
hr = this->ReturnString(flags, pszOut, pcchOut, contentType, strlenW(contentType) + 1);
Expand All @@ -355,16 +346,15 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
}
case ASSOCSTR_DEFAULTICON:
{
static const WCHAR DefaultIconW[] = L"DefaultIcon";
DWORD ret;
DWORD size = 0;
ret = RegGetValueW(this->hkeyProgID, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, NULL, &size);
if (ret == ERROR_SUCCESS)
{
WCHAR *icon = static_cast<WCHAR *>(HeapAlloc(GetProcessHeap(), 0, size));
if (icon)
{
ret = RegGetValueW(this->hkeyProgID, DefaultIconW, NULL, RRF_RT_REG_SZ, NULL, icon, &size);
ret = RegGetValueW(this->hkeyProgID, L"DefaultIcon", NULL, RRF_RT_REG_SZ, NULL, icon, &size);
if (ret == ERROR_SUCCESS)
{
hr = this->ReturnString(flags, pszOut, pcchOut, icon, strlenW(icon) + 1);
Expand All @@ -388,8 +378,7 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
}
case ASSOCSTR_SHELLEXTENSION:
{
static const WCHAR shellexW[] = L"ShellEx\\";
WCHAR keypath[sizeof(shellexW) / sizeof(shellexW[0]) + 39], guid[39];
WCHAR keypath[ARRAY_SIZE(L"ShellEx\\") + 39], guid[39];
CLSID clsid;
HKEY hkey;

Expand All @@ -398,7 +387,7 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetString(
{
return hr;
}
strcpyW(keypath, shellexW);
strcpyW(keypath, L"ShellEx\\");
strcatW(keypath, pszExtra);
LONG ret = RegOpenKeyExW(this->hkeySource, keypath, 0, KEY_READ, &hkey);
if (ret)
Expand Down Expand Up @@ -467,8 +456,6 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetKey(
*/
HRESULT STDMETHODCALLTYPE CQueryAssociations::GetData(ASSOCF cfFlags, ASSOCDATA assocdata, LPCWSTR pszExtra, LPVOID pvOut, DWORD *pcbOut)
{
static const WCHAR edit_flags[] = L"EditFlags";

TRACE("(%p,0x%8x,0x%8x,%s,%p,%p)\n", this, cfFlags, assocdata,
debugstr_w(pszExtra), pvOut, pcbOut);

Expand All @@ -488,7 +475,7 @@ HRESULT STDMETHODCALLTYPE CQueryAssociations::GetData(ASSOCF cfFlags, ASSOCDATA

void *data;
DWORD size;
HRESULT hres = this->GetValue(this->hkeyProgID, edit_flags, &data, &size);
HRESULT hres = this->GetValue(this->hkeyProgID, L"EditFlags", &data, &size);
if(FAILED(hres))
{
return hres;
Expand Down Expand Up @@ -582,8 +569,6 @@ HRESULT CQueryAssociations::GetCommand(const WCHAR *extra, WCHAR **command)
LONG ret;
WCHAR *extra_from_reg = NULL;
WCHAR *filetype;
static const WCHAR commandW[] = L"command";
static const WCHAR shellW[] = L"shell";

/* When looking for file extension it's possible to have a default value
that points to another key that contains 'shell/<verb>/command' subtree. */
Expand All @@ -597,17 +582,17 @@ HRESULT CQueryAssociations::GetCommand(const WCHAR *extra, WCHAR **command)

if (ret == ERROR_SUCCESS)
{
ret = RegOpenKeyExW(hkeyFile, shellW, 0, KEY_READ, &hkeyShell);
ret = RegOpenKeyExW(hkeyFile, L"shell", 0, KEY_READ, &hkeyShell);
RegCloseKey(hkeyFile);
}
else
{
ret = RegOpenKeyExW(this->hkeySource, shellW, 0, KEY_READ, &hkeyShell);
ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
}
}
else
{
ret = RegOpenKeyExW(this->hkeySource, shellW, 0, KEY_READ, &hkeyShell);
ret = RegOpenKeyExW(this->hkeySource, L"shell", 0, KEY_READ, &hkeyShell);
}

if (ret)
Expand Down Expand Up @@ -659,7 +644,7 @@ HRESULT CQueryAssociations::GetCommand(const WCHAR *extra, WCHAR **command)
return HRESULT_FROM_WIN32(ret);
}
/* open command subkey */
ret = RegOpenKeyExW(hkeyVerb, commandW, 0, KEY_READ, &hkeyCommand);
ret = RegOpenKeyExW(hkeyVerb, L"command", 0, KEY_READ, &hkeyCommand);
RegCloseKey(hkeyVerb);
if (ret)
{
Expand Down
3 changes: 1 addition & 2 deletions dll/win32/shell32/dialogs/dialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
{
const WCHAR *src;
WCHAR *dest, *result, *result_end=NULL;
static const WCHAR dotexeW[] = L".exe";

result = (WCHAR *)HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(strlenW(cmdline)+5));

Expand Down Expand Up @@ -466,7 +465,7 @@ static LPWSTR RunDlg_GetParentDir(LPCWSTR cmdline)
*dest = 0;
if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result))
break;
strcatW(dest, dotexeW);
strcatW(dest, L".exe");
if (INVALID_FILE_ATTRIBUTES != GetFileAttributesW(result))
break;
}
Expand Down
8 changes: 3 additions & 5 deletions dll/win32/shell32/dialogs/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,6 @@ ViewTree_LoadTree(HKEY hKey, LPCWSTR pszKeyName, DWORD dwParentID)

static BOOL ViewTree_LoadAll(VOID)
{
static const WCHAR s_szAdvanced[] =
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";

// free if already existed
if (s_ViewTreeEntries)
{
Expand All @@ -453,8 +450,9 @@ static BOOL ViewTree_LoadAll(VOID)
s_ViewTreeEntryCount = 0;

HKEY hKey;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, s_szAdvanced, 0,
KEY_READ, &hKey) != ERROR_SUCCESS)
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
0, KEY_READ, &hKey) != ERROR_SUCCESS)
{
return FALSE; // failure
}
Expand Down
3 changes: 1 addition & 2 deletions dll/win32/shell32/folders/CControlPanelFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,9 @@ HRESULT WINAPI CControlPanelFolder::Initialize(PCIDLIST_ABSOLUTE pidl)

/* Create the inner reg folder */
HRESULT hr;
static const WCHAR* pszCPanelPath = L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}";
hr = CRegFolder_CreateInstance(&CLSID_ControlPanel,
pidlRoot,
pszCPanelPath,
L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\\::{21EC2020-3AEA-1069-A2DD-08002B30309D}",
L"ControlPanel",
IID_PPV_ARG(IShellFolder2, &m_regFolder));
if (FAILED_UNEXPECTEDLY(hr))
Expand Down
12 changes: 4 additions & 8 deletions dll/win32/shell32/folders/CDrivesFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,6 @@ getIconLocationForDrive(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags,
WCHAR wszPath[MAX_PATH];
WCHAR wszAutoRunInfPath[MAX_PATH];
WCHAR wszValue[MAX_PATH], wszTemp[MAX_PATH];
static const WCHAR wszAutoRunInf[] = { 'a','u','t','o','r','u','n','.','i','n','f',0 };
static const WCHAR wszAutoRun[] = { 'a','u','t','o','r','u','n',0 };

// get path
if (!ILGetDisplayNameExW(psf, pidl, wszPath, 0))
Expand All @@ -422,10 +420,10 @@ getIconLocationForDrive(IShellFolder *psf, PCITEMID_CHILD pidl, UINT uFlags,

// build the full path of autorun.inf
StringCchCopyW(wszAutoRunInfPath, _countof(wszAutoRunInfPath), wszPath);
PathAppendW(wszAutoRunInfPath, wszAutoRunInf);
PathAppendW(wszAutoRunInfPath, L"autorun.inf");

// autorun.inf --> wszValue
if (GetPrivateProfileStringW(wszAutoRun, L"icon", NULL, wszValue, _countof(wszValue),
if (GetPrivateProfileStringW(L"autorun", L"icon", NULL, wszValue, _countof(wszValue),
wszAutoRunInfPath) && wszValue[0] != 0)
{
// wszValue --> wszTemp
Expand Down Expand Up @@ -977,8 +975,6 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla
{
WCHAR wszDrive[18] = {0};
DWORD dwVolumeSerialNumber, dwMaximumComponentLength, dwFileSystemFlags;
static const WCHAR wszOpenBracket[] = {' ', '(', 0};
static const WCHAR wszCloseBracket[] = {')', 0};

lstrcpynW(wszDrive, pszPath, 4);
pszPath[0] = L'\0';
Expand Down Expand Up @@ -1012,10 +1008,10 @@ HRESULT WINAPI CDrivesFolder::GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFla
pszPath[MAX_PATH-7] = L'\0';
}
}
wcscat (pszPath, wszOpenBracket);
wcscat (pszPath, L" (");
wszDrive[2] = L'\0';
wcscat (pszPath, wszDrive);
wcscat (pszPath, wszCloseBracket);
wcscat (pszPath, L")");
}

if (SUCCEEDED(hr))
Expand Down

0 comments on commit 83be315

Please sign in to comment.