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;}
I think the key you want is
HKEY_CLASSES_ROOT\Directory\Background
– Andrew Lambert – 2012-05-01T18:38:16.1171thanx @Amazed that was really close...
it is actually:
[HKEY_CLASSES_ROOT\Directory\Background\shell\commandNameHere]
– xero – 2012-05-01T18:54:07.4905solved for anyone interested here's the .REG file to add this functionality to the windows context menu:
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 – 2012-05-01T19:07:00.8272It's allowed and encouraged to answer your own questions. If you solved your problem, post an answer and accept it. – Dennis – 2012-06-06T14:12:17.137