Solved

Obtaining directory path through Windows

Posted on 2003-11-11
7
150 Views
Last Modified: 2010-05-03
Basically, I need to be able to click on a folder in say, Windows Explorer, then launch my VB program through the right-click context-menu. (the context-menu thing is no problem).

I need my VB program to be able to recognize what I am currently clicking on in the file system. (Basically what I've called it on) Is there any way to do this? (If not using VB then using ANY programming language. I know JAVA and C++ as well so either of those would be great.

For an example of what I've just asked:
If anyone has used winzip, basically u click on the file u want to zip, then you click "compress or zip or whatever in the context menu" and it knows what you're clicking on. I want to do the same thing except ONLY with folders, not files (if that makes it any simpler)

Thanks for your help.
0
Comment
Question by:John_2009
  • 3
7 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 125 total points
ID: 9727043
Command$ will represent the selected file or folder

Private Sub Form_Load()
If Trim$(Command$) <> "" Then
    MsgBox Command$
End If

End Sub
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9728223
Just make your context menu command call your app passing it %1.

So in the key HKEY_CLASSES_ROOT\Folder\Shell\MenuText\Command, (where MenuText is the text you want to appear in the context menu, and the value of Command is what to run when the menu item is clicked), you would put:

"full path to your app directory"\yourVBAppName.exe %1

Then in your VB app use code like this:

Option Explicit

Private Sub Form_Load()
    Dim coms As String
    coms = Trim(Command())
    If Len(coms) > 0 Then
        MsgBox "Called from folder: " & coms
    End If
End Sub
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 9872482
Did you ever get it to work John_2009?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 10164881
vinnyd79 should get the points.

Idle_Mind
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 10537276
Thanks for the guidance Idle_Mind.
Moderator, my recommended disposition is:

    Accept vinnyd79's comment(s) as an answer.

Dan Rollins -- EE database cleanup volunteer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question