Author: khornicek
Date: Fri Mar 3 16:20:03 2017
New Revision: 74039
URL:
http://svn.reactos.org/svn/reactos?rev=74039&view=rev
Log:
[SHELL32]
- Always set the default value in SetDefaultHandler, otherwise it's impossible to
create a default association if the key for some reason already exists. This is consistent
with what Windows does.
Modified:
trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp
trunk/reactos/dll/win32/shell32/COpenWithMenu.cpp
Modified: trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/CDefault…
==============================================================================
--- trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/CDefaultContextMenu.cpp [iso-8859-1] Fri Mar 3
16:20:03 2017
@@ -1019,7 +1019,7 @@
CDefaultContextMenu::DoDynamicShellExtensions(
LPCMINVOKECOMMANDINFO lpcmi)
{
- TRACE("verb %p first %x last %x", lpcmi->lpVerb, m_iIdSHEFirst,
m_iIdSHELast);
+ TRACE("verb %p first %x last %x\n", lpcmi->lpVerb, m_iIdSHEFirst,
m_iIdSHELast);
UINT idCmd = LOWORD(lpcmi->lpVerb);
PDynamicShellEntry pEntry = GetDynamicEntry(idCmd);
Modified: trunk/reactos/dll/win32/shell32/COpenWithMenu.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/shell32/COpenWit…
==============================================================================
--- trunk/reactos/dll/win32/shell32/COpenWithMenu.cpp [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/shell32/COpenWithMenu.cpp [iso-8859-1] Fri Mar 3 16:20:03
2017
@@ -684,10 +684,9 @@
BOOL COpenWithList::SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
{
HKEY hKey, hSrcKey, hDestKey;
- DWORD dwDisposition;
WCHAR wszBuf[256];
- TRACE("SetDefaultHandler %ls %ls", pApp->wszFilename, pwszFilename);
+ TRACE("SetDefaultHandler %ls %ls\n", pApp->wszFilename, pwszFilename);
/* Extract file extension */
LPCWSTR pwszExt = PathFindExtensionW(pwszFilename);
@@ -695,15 +694,18 @@
return FALSE;
/* Create file extension key */
- if (RegCreateKeyExW(HKEY_CLASSES_ROOT, pwszExt, 0, NULL, 0, KEY_READ|KEY_WRITE, NULL,
&hKey, &dwDisposition) != ERROR_SUCCESS)
+ if (RegCreateKeyExW(HKEY_CLASSES_ROOT, pwszExt, 0, NULL, 0, KEY_READ|KEY_WRITE, NULL,
&hKey, NULL) != ERROR_SUCCESS)
{
ERR("Cannot open ext key");
return FALSE;
}
- if (dwDisposition == REG_CREATED_NEW_KEY)
- {
- /* A new entry was created create the prog key id */
+ DWORD dwSize = sizeof(wszBuf);
+ LONG lResult = RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf,
&dwSize);
+
+ if (lResult == ERROR_FILE_NOT_FOUND)
+ {
+ /* A new entry was created or the default key is not set: set the prog key id */
StringCbPrintfW(wszBuf, sizeof(wszBuf), L"%s_auto_file", pwszExt + 1);
if (RegSetValueExW(hKey, L"", 0, REG_SZ, (const BYTE*)wszBuf,
(wcslen(wszBuf) + 1) * sizeof(WCHAR)) != ERROR_SUCCESS)
{
@@ -712,16 +714,11 @@
return FALSE;
}
}
- else
- {
- /* Entry already exists fetch prog key id */
- DWORD dwSize = sizeof(wszBuf);
- if (RegGetValueW(hKey, NULL, L"", RRF_RT_REG_SZ, NULL, wszBuf,
&dwSize) != ERROR_SUCCESS)
- {
- ERR("RegGetValueW failed: %lu\n", GetLastError());
- RegCloseKey(hKey);
- return FALSE;
- }
+ else if (lResult != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ ERR("RegGetValueExW failed: 0x%08x\n", lResult);
+ return FALSE;
}
/* Close file extension key */