Solved

Obtaining directory path through Windows

Posted on 2003-11-11
7
152 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
[X]
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
  • 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 86

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 86

Expert Comment

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 122
VBA filters 2 71
How to measure sizes and angles in scanned images ? 3 88
Macro Excel - Multiple If conditions 2 88
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

733 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