Registery edit
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
I use a reg file to create an explorer contextmenu item
When you right click and click MyItem which can only be shown if you right click a folder it opens my program, but how can i do so it add the folders destination and name to 2 diffrent textboxes in my program?
And how can i add this regestry key with vb.net?
When you right click and click MyItem which can only be shown if you right click a folder it opens my program, but how can i do so it add the folders destination and name to 2 diffrent textboxes in my program?
And how can i add this regestry key with vb.net?
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\MyItem]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\MyItem\command]
@="\"C:\\Users\\AnoPem\\Documents\\Visual Studio 2010\\Projects\\AP Lock\\AP Lock\\bin\\Debug\\MyProgram.exe\""
Code: Select all
In your load event, you can have this:
Dim k As RegistryKey = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Classes\Folder\shell\MyItem\command")
'k.SetValue("", "C:\Users\AnoPem\Documents\Visual Studio 2010\Projects\AP Lock\AP Lock\bin\Debug\MyProgram.exe")'
k.SetValue("", System.IO.Directory.GetCurrentDirectory() + "\MyProgram.exe %1")
Code: Select all
I think that would work. Didn't test it though.TextBox1.Text = System.Environment.GetCommandLineArgs()(0)
TextBox2.Text = System.IO.Directory.GetParent(TextBox1.Text).FullPath
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

M1z23R wrote:On form load use MsgBox(Command().tostring)This does not work :(
Well, did my work?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

MrAksel wrote:The registry add dosent work and i get this error on the form loadCode: Select allIn your load event, you can have this:Dim k As RegistryKey = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Classes\Folder\shell\MyItem\command") 'k.SetValue("", "C:\Users\AnoPem\Documents\Visual Studio 2010\Projects\AP Lock\AP Lock\bin\Debug\MyProgram.exe")' k.SetValue("", System.IO.Directory.GetCurrentDirectory() + "\MyProgram.exe %1")
Code: Select allI think that would work. Didn't test it though.TextBox1.Text = System.Environment.GetCommandLineArgs()(0) TextBox2.Text = System.IO.Directory.GetParent(TextBox1.Text).FullPath
Code: Select all
and the first line of the form load code only shows my programs path, i want the folder i right clicks pathError 1 'System.IO.FileSystemInfo.FullPath' is not accessible in this context because it is 'Protected'
Okay, replace the load code with this:
Code: Select all
TextBox1.Text = System.Environment.GetCommandLineArgs()(1)
TextBox2.Text = TextBox1.Text.Substring(TextBox1.Text.LastIndexOf("\"c) + 1)
TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.LastIndexOf("\"c))
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

MrAksel wrote:Okay, replace the load code with this:This does not work, i get this errorCode: Select allTextBox1.Text = System.Environment.GetCommandLineArgs()(1) TextBox2.Text = TextBox1.Text.Substring(TextBox1.Text.LastIndexOf("\"c) + 1) TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.LastIndexOf("\"c))
http://pastebin.com/HrGqAPED
Ive found a way to get the registry edited now i just need to know how i can load the path from the folder i right click into the program i open in the contextmenu
Blast your way lol. Fully working example for me.
Add to registry:
Add to registry:
Code: Select all
Load to textboxes:
Dim k As RegistryKey = Registry.LocalMachine.CreateSubKey("\SOFTWARE\Classes\Folder\shell\MyItem\command")
k.SetValue("", System.IO.Directory.GetCurrentDirectory() + "\MyProgram.exe /
folder:%1")
k.Close()
Code: Select all
Dim argument As String = ""
For Each arg As String In System.Environment.GetCommandLineArgs()
If arg.StartsWith("/folder:") Then
argument = arg.Substring(8)
Exit For
End If
Next
If argument <> "" AndAlso System.IO.Directory.Exists(argument) Then
Dim f As New DirectoryInfo(argument)
TextBox1.Text = f.Parent.FullName
TextBox2.Text = f.Name
Else
MessageBox.Show("Could not find folder.")
End If
Last edited by MrAksel on Tue May 15, 2012 7:40 pm, edited 1 time in total.
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

Copyright Information
Copyright © Codenstuff.com 2020 - 2023