Reputation: 3
I have created a very small project that consists of obtaining the path of a directory. for this I added a Textbox to the form which is the one that will show the collected path of the directory.
After compiling it I placed in: C:. and then I added it to the right-click mouse menu. but here comes my problem. my goal was to have my app to collect the path of the folder when ever I right-click and run my app in any folder I choose when right-clicking at it. for example: my documents, desktop, and so on. but instead my app always get the path where I placed it, in this case: C:.
I tried manually but I don't want to do it this way. In this example I have to run my project first and then drog and drop a file from that folder into the textbox.
Private Sub Command1_Click()
Dim strFullFilePath As String
strFullFilePath = Text1.Text
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Text2 = fso.GetParentFolderName(strFullFilePath)
End Sub
Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = Data.Files(1)
End Sub
I will appreciate any suggestion. I've searched the site for the same question as mine, but I did not find any.
Thanks in advance Regards
Upvotes: 0
Views: 335
Reputation: 258
Change the program's registration, adding "%V" at the end
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Project\command] @="C:\\Project.exe" "%V"
Explorer will then pass the directory to you on the command line. You can read command line parameters using the Command()
function in VB.
Private Sub Command1_Click()
Dim strFullFilePath As String
strFullFilePath = Text1.Text
Text2 = Command()
End Sub
Upvotes: 1