Windows right c. menu //help

Posts 1–10 of 10 · Page 1 of 1
Windows right c. menu //help
How to add application to right click c. menu

(Menu that pops up when you right click on desktop)

I know how to make that thing when you left click on folder, but that doesn't help me.

Here's code (R CLICK ON FOLDER):
Code:
 Dim argArray() As String = New String() {"-%1", "-arg2", "-arg3"}

Private Function doAddToList(ByVal itemName As String, ByVal itemPath As String, ByVal itemArgs() As String)
        Dim regkey : regkey = CreateObject("wscript.shell") : Dim keyValue = Chr(34) & itemPath & Chr(34)
        If Not itemArgs.Length < 1 Then
            For i = 0 To itemArgs.Length - 1
                keyValue &= itemArgs(i)
            Next
        End If
        Try
            regkey.regwrite("HKEY_CLASSES_ROOT\*\shell\" & itemName & "\command\", keyValue, "REG_SZ")
        Catch
            Return False
        End Try
        Return True
    End Function

Now, can sum1 give me code that the menu will appear w/o clicking on folder.

Explaination:

That's menu where i want my app to be displayed:




This is what i have done with the code:




thx!
@Blubb1337
@Jason
@NextGen1
@Hassan




Question no.2:

How to prevent closing of form and instead of closing hide...?

i putted me.hide under formclosing but didn't work
@/b/oss

You want to add a application to context menu for the desktop context menu?

If you are, Simply Create code to modify the registry.
You want to add a new key under
HKEY_CLASSES_ROOT\Directory\Background\shell\

as an example (don't do it programatically yet)

Let's use "test" as an example.
So navigate to the above, right click shell, add "test" as a new key (in regedit of course)
on the right where is says "default" Change it to "test"
Now goto desktop , right click, you will see test.
Now click on test (back in regedit) add a new key , call it command
On the left side where it says default, set the value to the application location.
"C:\windows\yada"
(or do you just want a command?)

Just make the code to modify registry and set application path = application start up path programatically.

For the hiding, put e.Cancel = True before the "Me.Hide" line.
@formclose

e.cancel = true

€: fu jason
you guys are fucking awesome

ng ill try in 1H
Quote Originally Posted by /b/oss View Post
you guys are fucking awesome

ng ill try in 1H
should be fine, just let us know.
Code:
 Private Function doAddToList(ByVal itemName As String, ByVal itemPath As String, ByVal itemArgs() As String)
        Dim regkey : regkey = CreateObject("wscript.shell") : Dim keyValue = Chr(34) & itemPath & Chr(34)
        If Not itemArgs.Length < 1 Then
            For i = 0 To itemArgs.Length - 1
                keyValue &= itemArgs(i)
            Next
        End If
        Try
            regkey.regwrite("HKEY_CLASSES_ROOT\Directory\Background\shell\" & itemName & "\command\", keyValue, "REG_SZ")
        Catch
            Return False
        End Try
        Return True
    End Function
Not working



e.cancel works
Quote Originally Posted by /b/oss View Post
Code:
 Private Function doAddToList(ByVal itemName As String, ByVal itemPath As String, ByVal itemArgs() As String)
        Dim regkey : regkey = CreateObject("wscript.shell") : Dim keyValue = Chr(34) & itemPath & Chr(34)
        If Not itemArgs.Length < 1 Then
            For i = 0 To itemArgs.Length - 1
                keyValue &= itemArgs(i)
            Next
        End If
        Try
            regkey.regwrite("HKEY_CLASSES_ROOT\Directory\Background\shell\" & itemName & "\command\", keyValue, "REG_SZ")
        Catch
            Return False
        End Try
        Return True
    End Function
Not working



also e.cencel doesn't work-

here's code:
Code:
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)

        e.Cancel = True
        Me.Hide()
        NotifyIcon2.Dispose()

    End Sub
You disposed the NotifyIcon...is that what you were intending to do? (Dispose is basically clearing it out of memory )
Quote Originally Posted by Jason View Post


You disposed the NotifyIcon...is that what you were intending to do? (Dispose is basically clearing it out of memory )
yes, already figured out lol.

and i forgot to add the handles thing

all i need now is context menu
@/b/oss, My code in test works fine for me.

[IMG]
http://img806.imageshack.us/img806/8838/works.jpg[/IMG] again, if that is what you are trying to do.

Didn't get to extensive, just did a quick test

[highlight=vbnet]
'Try
Dim rKey As RegistryKey
rKey = Registry.ClassesRoot.OpenSubKey("Directory\Backgro und\Shell", True)
rKey.CreateSubKey("MyApp")
rKey.Close()

Dim RegKey As RegistryKey
RegKey = Registry.ClassesRoot.OpenSubKey("Directory\Backgro und\Shell\MyApp", True)
RegKey.CreateSubKey("Command")
RegKey.SetValue("Default", "Open Notepad For M_T_H")
RegKey.close()




Dim FinalReg
FinalReg = Registry.ClassesRoot.OpenSubKey("Directory\Backgro und\Shell\MyApp\Command", True)
FinalReg.SetValue("Default", "C:\Windows\notepad.exe")
FinalReg.Close()


'Catch ex As Exception


' MsgBox(ex.Message)
'End Try
[/highlight]

It's Messy and quick, can be shorten a lot, originally just posted it one way, then made a mistake, then tested it, then posted it another way. So bare with the mess.

Posts 1–10 of 10 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Talk with us