Pass Path to VB App using Command Line switch

Discussion in 'AutoCAD' started by terencechatfielduk, Aug 11, 2003.

  1. I'd like to write a not too very complex sorting routine for autocad drawings, with the user running the program by selecting drawing file names in windows explorer, right clicking, then choosing 'Open With..' and selecting my program. But i don't know how to get the filename that might be passed to the VB app, and my routine just didn't seem to run at all. Anyone have any tips as to how this thing works? Does my program have to be 'registered' in the registry the way autocad is (not that i know how to do this?)
     
    terencechatfielduk, Aug 11, 2003
    #1
  2. To get the parameters passed to your executable, use the Command$ function. It
    returns a string containing the command line parameters. Then your program
    should work regardless of whether it is a registered application.

    with the user running the program by selecting drawing file names in windows
    explorer, right clicking, then choosing 'Open With..' and selecting my program.
    But i don't know how to get the filename that might be passed to the VB app, and
    my routine just didn't seem to run at all. Anyone have any tips as to how this
    thing works? Does my program have to be 'registered' in the registry the way
    autocad is (not that i know how to do this?)
     
    Chuck Gabriel, Aug 11, 2003
    #2
  3. I first tried the Command function, and then the Command$ function, and neither seems to work. The code i am using is in VB6 and very simple, as follows:

    Public Sub Main()
    MsgBox "Filename was " & Command$
    End Sub

    I don't even get the msgbox when i try and do the right-click to 'open with' in explorer. What am i doing wrong?
     
    terencechatfielduk, Aug 12, 2003
    #3
  4. Don't worry, found the answer! In the project properties i had 'unattended execution' ticked, so it didn't display any message boxes.

    Thanks for the assist.
     
    terencechatfielduk, Aug 12, 2003
    #4
  5. OK, now that works for 1 file. Whats the trick for getting filenames passed for multiple files, as the routine seems to run only once?
     
    terencechatfielduk, Aug 12, 2003
    #5
  6. I haven't learned that trick yet. If I do, I'll either post back here or start
    a new thread on the topic.

    for multiple files, as the routine seems to run only once?
     
    Chuck Gabriel, Aug 12, 2003
    #6
  7. Thanks.
     
    terencechatfielduk, Aug 12, 2003
    #7
  8. I've tried it, and it does work! Thanks.
     
    terencechatfielduk, Aug 12, 2003
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.