Shoutbox

Visual Basic and Registry - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Visual Basic and Registry (/showthread.php?tid=35591)

Visual Basic and Registry by DJeX on 12-13-2004 at 11:28 PM

How would I make my VB program handle out side commands? Such as, I would like to when I right click a file and click my program in the right click menu it will send a command to my program and my program will handle that file as coded in the program.

So far, I got my program to show in the right click menu by editing the registry. I have it now so it opens my program. But what I really want is when my program is click in the right click menu; I want that file that was right clicked to be moved to a different folder in the computer.

How could I set it up so my program will get the file name of the right clicked file and do the required commands coded in the program to handle that file?

I’m using Win XP.


RE: Visual Basic and Registry by Mike on 12-14-2004 at 05:54 AM

I have never used the right-click menu, but I believe that thats how windows is doing it because there cant be any other way!
Anyway, I believe that windows passes as a parametr the full path & the filename of the file to your program.
So, put

code:
MsgBox Command$
in your Form_Load sub, and see what parametr is passed to your program.
By doing this, I guess that you will understand what you have to do ;)

Beware in quotin marks!
I think Windows put quoting marks at the beggining and the ending if the path or filename have spaces.
So be sure to handle the filename with and without quotes :)

many typos in the post :dodgy:
RE: Visual Basic and Registry by CookieRevised on 12-14-2004 at 09:04 AM

also make sure your program can handle multiple files!... When using the right-click menu, Windows can paste more then 1 filename. Your program should be able to cope with that. Even if your program only needs 1 filename, it should be aware of this so you don't end up trying to move the file ""filename number 1.doc" "filename number 2.txt"" for example.


RE: Visual Basic and Registry by DJeX on 12-14-2004 at 10:15 PM

Yea I have the Command$ coded in my program. What I want to know is how I tell my program the file path of the file that is right clicked and my program is clicked in the menu.

Here is what I got in the start up of my program:


code:
Sub Main()
Dim FSO, FS
If Command$ <> "" Then
Set FSO = CreateObject("Scripting.FileSystemObject")
FS = FSO.MoveFile(Replace(Command$, Chr(34), vbNullString), "c:\Destroyer Deleted Files\")
FS = FSO.MoveFolder(Replace(Command$, Chr(34), vbNullString), "c:\Destroyer Deleted Files\")
    Else
        Form1.Show
    End If
End Sub

That code there only moves the file if it is dragged overtop of my program. Not right clicked.

How could I change that to do both? Right click and drag overtop.

RE: Visual Basic and Registry by Sk3tch on 12-15-2004 at 01:04 AM

Omg.. its been a while since i did stuff like this.. eehhmm..

the solution is not in your program, its in the Reg if im correct.

Whats your key, shell set as? Its should be something like this:
(Say its a text file)
HKEY_CLASSES_ROOT\txtfile\shell\"Open This.. " (Or whatever the key)

Then have the sub keys in "Open This.. " as:
command and ddeexec..  so you have those 2.

Make the Value in the "command" as the route to your program:

"C:\Documents and Settings\Sketch\Desktop\TEST.exe"
but then at the end add "%1" so you get:

"C:\Documents and Settings\Sketch\Desktop\TEST.exe""%1"

Make the ddeexec Value as:  Open("%1")

Now, in the key ddeexec add to more:  application and topic

In application give the app name (I think thats correct)
Then in topic put:  system


Now i haven't done this for ages so i could be wrong on some parts, but i think thats the basic jist of it. Try it out :-/


RE: Visual Basic and Registry by DJeX on 12-15-2004 at 03:01 AM

you've lost me, sorry.

Is the ddeexec supost to be my program name? and could you explain a little more about the reg keys I need to enter and where the Open("%1") goes.



Oh and I want it to be in every file I right click on including folders not just txtfiles.



*Forget my last post ^^^ I figured it out. It worked. Thanks!


**Ok say now if I want an icon next to my program name in the right click menu how would I add one?