Results 1 to 8 of 8

Thread: [Solved] Help with "Open with"

Threaded View

  1. #6
    Hyperactive Member stepdragon's Avatar
    Join Date
    Aug 2011
    Location
    Cincinnati
    Posts
    288

    Re: Help with "Open with"

    Well, first we need to understand what happens when you drag a file onto an exe in windows. Really all it does is open the exe with the file as a command line argument.

    for example writing:

    Test.exe file.txt

    in the command line
    would be the same as dragging file.txt onto test.exe in windows explorer.

    so to get that data, you would first need to know what is contained in that command line argument:

    vb.net Code:
    1. If Environment.GetCommandLineArgs.Count > 1 Then
    2.             MsgBox(Environment.GetCommandLineArgs(1).ToString)
    3. End If

    This will check to see if your program was launched with an argument (argument 0 is always your program itself). And then it shows what it is by using a messagebox.

    I'm pretty sure setting a file association works the same way, so if you associate a file with your program it will still open using this code.
    Last edited by stepdragon; Dec 2nd, 2011 at 03:01 PM. Reason: I said more than I needed so I removed it.

    If you're wrong, you'll learn. If I'm wrong, I'll learn. Try something new and go from there. That's how we improve.

    CodeBank: VB.Net - Simple Proper Image Scaling in Correct Aspect Ratio - Star Rating Control
    Useful Links: HOW TO USE CODE TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width