Buggie
Buggie

Reputation: 122

Directory Path from Right Click

I'm trying to write a program that can password protect individual folders, but I'm having a little trouble. I already have the option added to the context menu, but I don't know how to get the folder path that was right clicked on to open the context menu program.

Upvotes: 2

Views: 1788

Answers (2)

rhythmo
rhythmo

Reputation: 949

Here is what worked for me. The code below can be run as a .reg(opens with Registry Editor) file to add the menu item "WinSearch" to the top and a submenu item "Launch" (See image below). It also adds separate icons for each item.

enter image description here

[HKEY_CLASSES_ROOT\Directory\Background\shell\WinSearch]
"SubCommands"="Launch"
"Icon"="C:\\Temp\\logo.ico"
"Position"="Top"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Launch]
@="Launch"
"Icon"="C:\\Temp\\Search.ico"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\Launch\command]
@="\"C:\\users\\me\\Desktop\\WinSearch.exe\" \"%V\""

The %V in the above last command will pass the folder path as an argument to the WinSearch.exe file. But the exe file should have provision to receive the arguments.

Upvotes: 2

Matt Cofer
Matt Cofer

Reputation: 2982

The OS should pass the path to your program as an argument. It should be the first one. You would just need to capture the command line arguments in your code.

C# - Arguments for application

Upvotes: 1

Related Questions