Solved

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

Posted on 2007-11-29
5
167 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

791 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