Solved

Obtaining directory path through Windows

Posted on 2003-11-11
7
148 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now