mirror of
https://github.com/reactos/reactos.git
synced 2025-05-17 16:27:00 +00:00
[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. svn path=/trunk/; revision=74039
This commit is contained in:
parent
c1bfc56213
commit
ee917ebd77
2 changed files with 12 additions and 15 deletions
|
@ -1019,7 +1019,7 @@ HRESULT
|
|||
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);
|
||||
|
|
|
@ -684,10 +684,9 @@ BOOL COpenWithList::AddAppToMRUList(SApp *pApp, LPCWSTR pwszFilename)
|
|||
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 @@ BOOL COpenWithList::SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
|
|||
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)
|
||||
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 create the prog key id */
|
||||
/* 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 @@ BOOL COpenWithList::SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
|
|||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (lResult != ERROR_SUCCESS)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
ERR("RegGetValueExW failed: 0x%08x\n", lResult);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Close file extension key */
|
||||
|
|
Loading…
Reference in a new issue