Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Start program by dragging file onto exe

Start program by dragging file onto exe

Scheduled Pinned Locked Moved Visual Basic
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johnjsm
    wrote on last edited by
    #1

    Hi, Is it possible or how do you create a exe that when you drop a file onto it, the program will run and do a task on the file that your dragged onto it.

    G 1 Reply Last reply
    0
    • J johnjsm

      Hi, Is it possible or how do you create a exe that when you drop a file onto it, the program will run and do a task on the file that your dragged onto it.

      G Offline
      G Offline
      Gideon Engelberth
      wrote on last edited by
      #2

      When you drag a file over an exe (or shortcut), the program will be started with the filename as a command line argument. You can either change Sub Main() to Sub Main(args() As String) or find some other way to get the command line arguments (System.Environment.GetCommandLineArgs(), for example). Something similar happens if you associate a file type with your program and double-click the file in explorer.

      J 1 Reply Last reply
      0
      • G Gideon Engelberth

        When you drag a file over an exe (or shortcut), the program will be started with the filename as a command line argument. You can either change Sub Main() to Sub Main(args() As String) or find some other way to get the command line arguments (System.Environment.GetCommandLineArgs(), for example). Something similar happens if you associate a file type with your program and double-click the file in explorer.

        J Offline
        J Offline
        johnjsm
        wrote on last edited by
        #3

        I will try explain what I am trying to do a little better than before. I have a program that when you run it the Open FIle Dialog appears so you can select a pdf to run a check on. What I want to do is to allow the user to drag and drop the pdf onto the exe an instead of opening the Open File dialog it would bypass it but still use the file name and path that I have selected as the file to check. An example of this would be if you create a text file on your desktop. You can then drag and drop the file on Notepad.exe and the file will open straight away.

        modified on Thursday, July 3, 2008 10:46 AM

        T G 2 Replies Last reply
        0
        • J johnjsm

          I will try explain what I am trying to do a little better than before. I have a program that when you run it the Open FIle Dialog appears so you can select a pdf to run a check on. What I want to do is to allow the user to drag and drop the pdf onto the exe an instead of opening the Open File dialog it would bypass it but still use the file name and path that I have selected as the file to check. An example of this would be if you create a text file on your desktop. You can then drag and drop the file on Notepad.exe and the file will open straight away.

          modified on Thursday, July 3, 2008 10:46 AM

          T Offline
          T Offline
          Tom Deketelaere
          wrote on last edited by
          #4

          Gideon provided you with the answer you need When you drop a file onto you'r exe, the exe will start with in its arguments the path to that file like gideon said you can then eighter change the constructor of you'r startupform form public sub new() to public sub new(args() as string) or use System.Environment.GetCommandLineArgs() to get the arguments passed to the exe this is a standerd function in windows (drop any file onto (olmost) any exe and the exe will start) But all this has been said by Gideon so...

          1 Reply Last reply
          0
          • J johnjsm

            I will try explain what I am trying to do a little better than before. I have a program that when you run it the Open FIle Dialog appears so you can select a pdf to run a check on. What I want to do is to allow the user to drag and drop the pdf onto the exe an instead of opening the Open File dialog it would bypass it but still use the file name and path that I have selected as the file to check. An example of this would be if you create a text file on your desktop. You can then drag and drop the file on Notepad.exe and the file will open straight away.

            modified on Thursday, July 3, 2008 10:46 AM

            G Offline
            G Offline
            Gideon Engelberth
            wrote on last edited by
            #5

            I haven't done that myself, but this article has a basic tutorial that should point you in the right direction. The main events here seem to be DragEnter and DragDrop.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups