CE

CE

  • NA
  • 1
  • 732

How to fetch the value on the click of Context Menu Item.

Mar 3 2015 4:43 AM
I have a created a custom context menu on right click of any file/folder - "Universal Send to" as part of main context menu in the registry using Microsoft.Win32 class in C#. 
The sub menu items to this menu are the names of PC's in the network and I've coded such that they get added dynamically whenever a device is detected in the network. 
I have added a property 'IP address' to its sub context menu item in the registry. I have a single executable (-FileTransfer.exe) for all the context items (like HomePC, OfficePC, etc..), that transfers the file/folder to the selected PC. 
However, I am not able to make it work for dynamic Pc's as I am not able to fetch the IP address for the selected device and pass the same as a parameter to the executable.

Below are some snapshots of what I have made so far.





C# Code snippet: (Hardcoded HomePC in registry now for test purpose):
RegistryKey key;

key = Registry.ClassesRoot.CreateSubKey(@"*\shell\UniSendTo");

string MUIVerb = "Universal Send To";

string ExtendedSubCommandsKey = @"*\shell\UniSendTo\MainMenu";

key.SetValue("MUIVerb", MUIVerb);

key.SetValue("ExtendedSubCommandsKey",ExtendedSubCommandsKey);

RegistryKey key1 = Registry.ClassesRoot.CreateSubKey(@"*\shell\UniSendTo\MainMenu");

key1 = Registry.ClassesRoot.CreateSubKey(@"*\shell\UniSendTo\MainMenu\shell");

RegistryKey key2 = Registry.ClassesRoot.CreateSubKey(@"*\shell\UniSendTo\MainMenu\shell\HomePC");

string MUIVerb1 = "Home PC"; key2.SetValue("MUIVerb",MUIVerb1); string ip = "192.168.1.22";
key2
.SetValue("IP",ip);

RegistryKey key3 = Registry.ClassesRoot.CreateSubKey(@"*\shell\UniSendTo\MainMenu\shell\HomePC\command");

key3.SetValue("",@"H:\ERT\FileTransfer.exe");