[SHELL32][BOOTDATA] Implement Command Prompt here (#2029)

Add "Command Prompt here" menu item to the Right-click menu of normal folders and drives. Currently, this menu item doesn't work correctly because of the bug of pushd. CORE-12150
This commit is contained in:
Katayama Hirofumi MZ 2019-11-14 23:25:21 +09:00 committed by GitHub
parent e753d5e108
commit 90c63d12a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 129 additions and 27 deletions

View file

@ -26,6 +26,22 @@ HKCR,"Folder\shell\explore","BrowserFlags",0x00010001,"0x00000022"
HKCR,"Folder\shell\explore","ExplorerFlags",0x00010001,"0x00000021"
HKCR,"Folder\shell\explore\command","",0x00000000,"explorer.exe /e,""%1"""
; Directory
HKCR,"Directory","",0x00000000,"File Folder"
;HKCR,"Directory\DefaultIcon","",0x00000000,"%SystemRoot%\system32\shell32.dll,-4"
HKCR,"Directory","AlwaysShowExt",0x00000000,""
HKCR,"Directory","NoRecentDocs",0x00000000,""
HKCR,"Directory\shell\cmd","",0x00020000,"@%SystemRoot%\system32\shell32.dll,-306"
HKCR,"Directory\shell\cmd","Extended",0x00000000,""
HKCR,"Directory\shell\cmd\command","",0x00000000,"cmd /s /k pushd ""%V"""
; Drive
HKCR,"Drive","",0x00000000,"Drive"
;HKCR,"Drive\DefaultIcon","",0x00000000,"%SystemRoot%\system32\shell32.dll,-4"
HKCR,"Drive\shell\cmd","",0x00020000,"@%SystemRoot%\system32\shell32.dll,-306"
HKCR,"Drive\shell\cmd","Extended",0x00000000,""
HKCR,"Drive\shell\cmd\command","",0x00000000,"cmd /s /k pushd ""%V"""
; Clipboard Element
HKCR,".clp","",0x00000000,"clpfile"
HKCR,".clp","Content Type",0x00000000,"application/x-msclip"

View file

@ -562,49 +562,62 @@ CDefaultContextMenu::AddStaticContextMenusToMenu(
/* By default use verb for menu item name */
mii.dwTypeData = pEntry->szVerb;
WCHAR wszKey[256];
HRESULT hr;
hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
if (FAILED_UNEXPECTEDLY(hr))
{
pEntry = pEntry->pNext;
continue;
}
BOOL Extended = FALSE;
HKEY hkVerb;
if (idResource > 0)
{
if (LoadStringW(shell32_hInstance, idResource, wszVerb, _countof(wszVerb)))
mii.dwTypeData = wszVerb; /* use translated verb */
else
ERR("Failed to load string\n");
LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
if (res == ERROR_SUCCESS)
{
res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
Extended = (res == ERROR_SUCCESS);
RegCloseKey(hkVerb);
}
}
else
{
WCHAR wszKey[256];
HRESULT hr = StringCbPrintfW(wszKey, sizeof(wszKey), L"shell\\%s", pEntry->szVerb);
if (SUCCEEDED(hr))
LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
if (res == ERROR_SUCCESS)
{
HKEY hkVerb;
DWORD cbVerb = sizeof(wszVerb);
LONG res = RegOpenKeyW(pEntry->hkClass, wszKey, &hkVerb);
res = RegLoadMUIStringW(hkVerb, NULL, wszVerb, cbVerb, NULL, 0, NULL);
if (res == ERROR_SUCCESS)
{
res = RegLoadMUIStringW(hkVerb,
NULL,
wszVerb,
cbVerb,
NULL,
0,
NULL);
if (res == ERROR_SUCCESS)
{
/* use description for the menu entry */
mii.dwTypeData = wszVerb;
}
RegCloseKey(hkVerb);
/* use description for the menu entry */
mii.dwTypeData = wszVerb;
}
res = RegQueryValueExW(hkVerb, L"Extended", NULL, NULL, NULL, NULL);
Extended = (res == ERROR_SUCCESS);
RegCloseKey(hkVerb);
}
}
mii.cch = wcslen(mii.dwTypeData);
mii.fState = fState;
mii.wID = iIdCmdFirst + cIds;
InsertMenuItemW(hMenu, *pIndexMenu, TRUE, &mii);
(*pIndexMenu)++;
cIds++;
if (!Extended || GetAsyncKeyState(VK_SHIFT) < 0)
{
mii.cch = wcslen(mii.dwTypeData);
mii.fState = fState;
mii.wID = iIdCmdFirst + cIds;
InsertMenuItemW(hMenu, *pIndexMenu, TRUE, &mii);
(*pIndexMenu)++;
cIds++;
}
pEntry = pEntry->pNext;

View file

@ -911,6 +911,7 @@ BEGIN
IDS_EDIT_VERB "Обработка"
IDS_FIND_VERB "Търсене"
IDS_PRINT_VERB "Разпечатване"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u файла, %u папки"
IDS_PRINTERS "Печатачи"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -916,6 +916,7 @@ BEGIN
IDS_EDIT_VERB "Upravit"
IDS_FIND_VERB "Najít"
IDS_PRINT_VERB "Tisknout"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u souborů, %u složek"
IDS_PRINTERS "Tiskárny"

View file

@ -916,6 +916,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -911,6 +911,7 @@ BEGIN
IDS_EDIT_VERB "Bearbeiten"
IDS_FIND_VERB "Finden"
IDS_PRINT_VERB "Drucken"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Dateien, %u Ordner"
IDS_PRINTERS "Drucker"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -918,6 +918,7 @@ BEGIN
IDS_EDIT_VERB "Editar"
IDS_FIND_VERB "Buscar"
IDS_PRINT_VERB "Imprimir"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u archivos, %u carpetas"
IDS_PRINTERS "Impresoras"

View file

@ -917,6 +917,7 @@ BEGIN
IDS_EDIT_VERB "Muuda"
IDS_FIND_VERB "Leia"
IDS_PRINT_VERB "Prindi"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Faili, %u Kausta"
IDS_PRINTERS "Printerid"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Éditer"
IDS_FIND_VERB "Chercher"
IDS_PRINT_VERB "Imprimer"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u fichiers, %u répertoires"
IDS_PRINTERS "Imprimantes"

View file

@ -912,6 +912,7 @@ BEGIN
IDS_EDIT_VERB "ערוך"
IDS_FIND_VERB "מצא"
IDS_PRINT_VERB "הדפס"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u קבצים, %u תיקיות"
IDS_PRINTERS "מדפסות"

View file

@ -905,6 +905,7 @@ BEGIN
IDS_EDIT_VERB "संपादित करें"
IDS_FIND_VERB "ढूंढे"
IDS_PRINT_VERB "प्रिंट"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u फ़ाइलें, %u फ़ोल्डर"
IDS_PRINTERS "प्रिंटर"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Cari"
IDS_PRINT_VERB "Cetak"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Berkas, %u Folder"
IDS_PRINTERS "Printer"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Modifica"
IDS_FIND_VERB "Cerca"
IDS_PRINT_VERB "Stampa"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u File, %u Cartelle"
IDS_PRINTERS "Stampanti"

View file

@ -907,6 +907,7 @@ BEGIN
IDS_EDIT_VERB "編集"
IDS_FIND_VERB "検索"
IDS_PRINT_VERB "印刷"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u 個のファイル、 %u 個のフォルダ"
IDS_PRINTERS "プリンタ"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Rediger"
IDS_FIND_VERB "Finn"
IDS_PRINT_VERB "Skriv ut"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u filer, %u mapper"
IDS_PRINTERS "Skrivere"

View file

@ -915,6 +915,7 @@ BEGIN
IDS_EDIT_VERB "Edytuj"
IDS_FIND_VERB "Wyszukaj"
IDS_PRINT_VERB "Drukuj"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Plików, %u Katalogów"
IDS_PRINTERS "Drukarki"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Editar"
IDS_FIND_VERB "Procurar"
IDS_PRINT_VERB "Imprimir"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Arquivos, %u Pastas"
IDS_PRINTERS "Impressoras"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Editar"
IDS_FIND_VERB "Procurar"
IDS_PRINT_VERB "Imprimir"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Ficheiros, %u Pastas"
IDS_PRINTERS "Impressoras"

View file

@ -912,6 +912,7 @@ BEGIN
IDS_EDIT_VERB "Editează"
IDS_FIND_VERB "Caută"
IDS_PRINT_VERB "Imprimă"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u fișiere, %u dosare"
IDS_PRINTERS "Imprimante"

View file

@ -917,6 +917,7 @@ BEGIN
IDS_EDIT_VERB "Изменить"
IDS_FIND_VERB "Поиск"
IDS_PRINT_VERB "Печать"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u файлов, %u папок"
IDS_PRINTERS "Принтеры"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Upraviť"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Tlačiť"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "súbory: %u, priečinky: %u"
IDS_PRINTERS "Tlačiarne"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Edit"
IDS_FIND_VERB "Find"
IDS_PRINT_VERB "Print"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Files, %u Folders"
IDS_PRINTERS "Printers"

View file

@ -914,6 +914,7 @@ BEGIN
IDS_EDIT_VERB "Modifiko"
IDS_FIND_VERB "Gjej"
IDS_PRINT_VERB "Printo"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Dokumenta, %u Dosje"
IDS_PRINTERS "Printera"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Redigera"
IDS_FIND_VERB "Hitta"
IDS_PRINT_VERB "Skriv ut"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u filer, %u mappar"
IDS_PRINTERS "Skrivare"

View file

@ -912,6 +912,7 @@ BEGIN
IDS_EDIT_VERB "Düzenle"
IDS_FIND_VERB "Bul"
IDS_PRINT_VERB "Yazdır"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u Kütük, %u Dizin"
IDS_PRINTERS "Yazıcılar"

View file

@ -910,6 +910,7 @@ BEGIN
IDS_EDIT_VERB "Змінити"
IDS_FIND_VERB "Пошук"
IDS_PRINT_VERB "Друк"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u файлів, %u папок"
IDS_PRINTERS "Принтери"

View file

@ -920,6 +920,7 @@ BEGIN
IDS_EDIT_VERB "编辑"
IDS_FIND_VERB "查找"
IDS_PRINT_VERB "打印"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u 个文件,%u 个文件夹"
IDS_PRINTERS "打印机"

View file

@ -921,6 +921,7 @@ BEGIN
IDS_EDIT_VERB "編輯"
IDS_FIND_VERB "搜索"
IDS_PRINT_VERB "列印"
IDS_CMD_VERB "Command Prompt here"
IDS_FILE_FOLDER "%u 個檔案, %u 個檔案夾"
IDS_PRINTERS "印表機"

View file

@ -3,7 +3,7 @@
*
* Copyright 1998 Marcus Meissner
* Copyright 2002 Eric Pouech
* Copyright 2018 Katayama Hirofumi MZ
* Copyright 2018-2019 Katayama Hirofumi MZ
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -167,6 +167,8 @@ static void ParseTildeEffect(PWSTR &res, LPCWSTR &args, DWORD &len, DWORD &used,
* %I address of a global item ID (explorer switch /idlist)
* %L seems to be %1 as long filename followed by the 8+3 variation
* %S ???
* %W Working directory
* %V Use either %L or %W
* %* all following parameters (see batfile)
*
* The way we parse the command line arguments was determined through extensive
@ -302,6 +304,42 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
found_p1 = TRUE;
break;
case 'w':
case 'W':
if (lpDir)
{
used += wcslen(lpDir);
if (used < len)
{
wcscpy(res, lpDir);
res += wcslen(lpDir);
}
}
break;
case 'v':
case 'V':
if (lpFile)
{
used += wcslen(lpFile);
if (used < len)
{
wcscpy(res, lpFile);
res += wcslen(lpFile);
}
found_p1 = TRUE;
}
else if (lpDir)
{
used += wcslen(lpDir);
if (used < len)
{
wcscpy(res, lpDir);
res += wcslen(lpDir);
}
}
break;
case 'i':
case 'I':
if (pidl)

View file

@ -200,6 +200,7 @@
#define IDS_EDIT_VERB 303
#define IDS_FIND_VERB 304
#define IDS_PRINT_VERB 305
#define IDS_CMD_VERB 306
#define IDS_FILE_FOLDER 308
#define IDS_CREATELINK 309