Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Obtaining directory path through Windows

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA to copy paste columns form one file to other 20 90
passing parameter in sql procedure 9 65
Using "ScreenUpdating" 6 73
checkbox to hide entire section 10 41
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

840 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