From f4edca4243d83695417682e1d55cb279674c7ed7 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Mon, 3 Dec 2007 23:33:36 +0000 Subject: [PATCH] - show nice display name when full path for executable is available - enumerate default open verb too - look in HKCR progid for default verbs/file associations - fix a bug in SHEOW_LoadOpenWithItems svn path=/trunk/; revision=30992 --- reactos/dll/win32/shell32/she_ocmenu.c | 57 ++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/reactos/dll/win32/shell32/she_ocmenu.c b/reactos/dll/win32/shell32/she_ocmenu.c index c0c763056c8..1b7b8cb3334 100644 --- a/reactos/dll/win32/shell32/she_ocmenu.c +++ b/reactos/dll/win32/shell32/she_ocmenu.c @@ -164,6 +164,7 @@ AddItems(SHEOWImpl *This, HMENU hMenu, UINT idCmdFirst) MENUITEMINFOW mii; WCHAR szBuffer[MAX_PATH]; UINT index; + WCHAR * szPtr; static const WCHAR szChoose[] = { 'C','h','o','o','s','e',' ','P','r','o','g','r','a','m','.','.','.',0 }; ZeroMemory(&mii, sizeof(mii)); @@ -175,7 +176,26 @@ AddItems(SHEOWImpl *This, HMENU hMenu, UINT idCmdFirst) for (index = 0; index < This->count; index++) { mii.wID = idCmdFirst; - mii.dwTypeData = (LPWSTR)This->szArray[index]; + szPtr = wcsrchr(This->szArray[index], L'\\'); + if (!szPtr) + { + szPtr = This->szArray[index]; + } + else + { + /* remove backslash from path */ + szPtr++; + } + + wcscpy(szBuffer, szPtr); + szPtr = wcsrchr(szBuffer, L'.'); + if (szPtr) + { + /* remove .exe part from display list */ + szPtr[0] = 0; + } + + mii.dwTypeData = szBuffer; if (InsertMenuItemW(hMenu, -1, TRUE, &mii)) { idCmdFirst++; @@ -1012,6 +1032,31 @@ SHEOW_LoadItemFromHKCR(SHEOWImpl *This, WCHAR * szExt) if (result != ERROR_SUCCESS) return NumKeys; + result = RegOpenKeyExW(hKey, + L"shell\\open\\command", + 0, + KEY_READ | KEY_QUERY_VALUE, + &hSubKey); + + if (result == ERROR_SUCCESS) + { + WCHAR szBuffer[MAX_PATH+10]; + WCHAR * ptr; + DWORD dwBuffer = sizeof(szBuffer); + + if (RegGetValueW(hSubKey, NULL, NULL, RRF_RT_REG_SZ, NULL, (PVOID)szBuffer, &dwBuffer) == ERROR_SUCCESS) + { + ptr = wcsrchr(szBuffer, L' '); + if (ptr) + { + /* erase %1 or extra arguments */ + ptr[0] = 0; + } + SHEOW_AddOWItem(This, szBuffer); + } + RegCloseKey(hSubKey); + } + result = RegOpenKeyExW(hKey, szCROW, 0, @@ -1196,13 +1241,17 @@ SHEOW_LoadOpenWithItems(SHEOWImpl *This, IDataObject *pdtobj) } SHEOW_LoadItemFromHKCU(This, szPtr); - SHEOW_LoadItemFromHKCR(This, szPtr); - dwPath = sizeof(szPath); - if (RegGetValueW(HKEY_CLASSES_ROOT, szPtr, NULL, RRF_RT_REG_SZ, NULL, szPath, &dwPath) == ERROR_SUCCESS) + if (RegGetValueW(HKEY_CURRENT_USER, szPtr, NULL, RRF_RT_REG_SZ, NULL, szPath, &dwPath) == ERROR_SUCCESS) { SHEOW_LoadItemFromHKCU(This, szPath); } + SHEOW_LoadItemFromHKCR(This, szPtr); + dwPath = sizeof(szPath); + if (RegGetValueW(HKEY_CLASSES_ROOT, szPtr, NULL, RRF_RT_REG_SZ, NULL, szPath, &dwPath) == ERROR_SUCCESS) + { + SHEOW_LoadItemFromHKCR(This, szPath); + } } TRACE("count %u\n", This->count); return S_OK;