Solved

Creating program to add functionality to right click context menu. Need to grab all command line arguments.

Posted on 2007-11-29
5
165 Views
Last Modified: 2013-11-26
I am working on creating a small app that will allow a user to right click on one (or more) files in a directory and click on "Create PDF's" or "Combine All Into 1 PDF".

I am using PDF Creators COM interface and I have all of that programming done. What I need to do is be able to read in multiple file names. So whether the user right clicks on one file or multiples, I will be able to read all of the file names into variables and then perform the requested action.

So I guess I just need help reading command line arguments and determining how many were passed.

Thanks,

Ryan
0
Comment
Question by:EOGRIS
  • 3
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
jcoehoorn earned 500 total points
ID: 20375426
If you're staring up a form directly, you need to use a module instead.  Create a new module with a public sub named "Main" like this:
Module MainModule
    Public Sub Main(ByVal CmdArgs() As String)
        '...
    End Sub
End Module

Then to use that sub go to the project's properties page, make sure "Enable Application Framework" is NOT checked, and you should be able to choos "Sub Main" as a start up object.  Now if you need to show a form you can do so from the sub, and the command line arguments are available in the CmdArgs parameter for the sub.
0
 

Author Comment

by:EOGRIS
ID: 20381487
Okay I got that part, but I don't know how to break out the different file names.

So if someone right clicks on like 4 files, and then selects my application in the context menu, those 4 file names will be sent as command line arguments to my application. So I need to know how to seperate those file names out, probably using an array.

Just can't find the right code.
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20381989
CmdArgs is already an array, and should hold one file name at each index.
0
 

Author Comment

by:EOGRIS
ID: 20382034
Okay so I just need to check the length of CmdArgs and then loop through it to get all the file names that were passed to it?
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 20382092
Yep.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

863 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

23 Experts available now in Live!

Get 1:1 Help Now