0

I'm working on a program that is associated with a file type ".gif" and whenever i open an .gif image anywhere on the PC, it would get the path of the file and set it as Picturebox.imageLocation

I've been Googling for the answer and i can't seem to find correct words to find it. I've seen few videos and they use preset location, so that doesn't help me much.

NeedsHelp
  • 1
  • 1

1 Answers1

0

Do you have the ".gif" file association already set up? If not, see Associating file extensions with a program

Once you have that part done, you should have something in the registry like this:

HKEY_CURRENT_USER\Software\Classes\yourcorpname.yourappname.v1\shell\open\command", null, @"c:\path\to\app.exe \"%1\""

When the file is opened the %1 is replaced with the path of the file. You just need to make a Main method that has parameters:

Sub Main(ByVal cmdArgs() As String)
    MsgBox("The Main procedure is starting the application.")
    Dim returnValue As Integer = 0
    ' See if there are any arguments.
    If cmdArgs.Length > 0 Then
        Dim pathToGifFile As String = cmdArgs(0)
        ' Now you have the path to the picture to add to the PictureBox
    End If
    ' Insert call to appropriate starting place in your code.
    MsgBox("The application is terminating.")
End Sub
Community
  • 1
  • 1
Swoogan
  • 5,298
  • 5
  • 35
  • 47