폴더의 상황에 맞는 메뉴에 항목을 어떻게 추가합니까?

폴더의 상황에 맞는 메뉴에 항목을 어떻게 추가합니까?

실제 폴더를 클릭할 때 상황에 맞는 메뉴를 추가하는 방법을 알고 있습니다.

[HKEY_CLASSES_ROOT\Directory\shell\commandNameHere]

하지만 아무것도 클릭하지 않는 것은 어떨까요?폴더에?

마치 데스크탑에 새 폴더를 만드는 것처럼 두 번 클릭하여 폴더에 들어간 다음 아무 것도 마우스 오른쪽 버튼으로 클릭하지 않으면(폴더가 비어 있음) 이제 이 상황에서 상황에 맞는 메뉴가 나타나기를 원합니다.

답변1

.reg관심 있는 분들을 위해 Windows 상황에 맞는 메뉴에 이 기능을 추가하는 파일은 다음과 같습니다 .

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Shell]
@="none"
[HKEY_CLASSES_ROOT\Directory\shell\gitBashHere]
[HKEY_CLASSES_ROOT\Directory\Background\shell\gitBashHere]
"Icon"="C:\\icons\\git-gui.ico"
"MUIVerb"="git bash here"
"Position"="bottom" 
[HKEY_CLASSES_ROOT\Directory\shell\gitBashHere\command] 
[HKEY_CLASSES_ROOT\Directory\Background\shell\gitBashHere\command]
@="C:\\Program Files\\Console2\\Console.exe -d %v"

(에서 가져옴xero의 코멘트)

이렇게 하면 콘솔을 여는 아이콘과 함께 "git bash here"라는 컨텍스트 메뉴에 명령이 추가됩니다.

명령은 다음 두 가지 모두에 추가됩니다.

  • HKEY_CLASSES_ROOT\Directory\shell, 폴더를 마우스 오른쪽 버튼으로 클릭하면 나타나는 상황에 맞는 메뉴
  • HKEY_CLASSES_ROOT\Directory\background, 폴더에 있는 동안 "배경" 빈 공간을 마우스 오른쪽 버튼으로 클릭하면 나타나는 상황에 맞는 메뉴

답변2

void WriteContextMenu(LPSTR key, LPSTR value) {

HKEY hkey=0; DWORD disp;

if(RegCreateKeyEx(HKEY_CLASSES_ROOT, key, 0, NULL, REP_OPTION_NON_VOLATILE, KEY_WRITE,NULL, &hkey, &disp)!=ERROR_SUCCESS) 

{

     if(RegOpenKey(HKEY_CLASSES_ROOT,key,&hkey)!=ERROR_SUCCESS)
    {   

      cout<<"Unable to open Registry"<<key;

        }

}if(RegSetValueEx(hkey,TEXT(""),0,REG_SZ,(LPBYTE)value, strlen(value)*sizeof(char))!=ERROR_SUCCESS)

{

   RegCloseKey(hkey);

       cout<<"Unable to set Registry Value ";

} else{

   cout<<value<<" value has set"<<endl;
}
}int main(){LPSTR key="Folder\\shell\\Testing_App"; 

 LPSTR valueKey="Menu_Title";

 LPSTR Subkey="Folder\\shell\\Testing_App\\command";


/*Here put the path or action you want to perform like you want to
    open cmd  on your context menu so the value id */

    LPSTR valueSubKey="cmd.exe";

    WriteContextMenu(key, ValueKey); 
    WriteContextMenu(Subkey, ValueSubKey);

return 0;}

답변3

모든 상황에 맞는 메뉴에 대한 하나의 솔루션은 다음과 같습니다.

https://stackoverflow.com/questions/20449316/how-add-context-menu-item-to-windows-explorer-for-folders/20458056#20458056

그러나 %1이(가) 하나만 사용하므로 여러 디렉터리나 파일을 이 컨텍스트 메뉴에 인수로 전달하는 방법은 여러 파일을 Ctrl 키를 누른 채 클릭하면 모든 파일을 인수로 보내는 대신 실행 파일을 여러 번 엽니다.

관련 정보