Home All Groups Group Topic Archive Search About

Launch a program and a function by File Type

Author
25 Jan 2006 11:12 PM
bidalah
Hi,

I have created a program which opens up ".pcfs" files, a kind of text
file unique to my program.  I want to be able to click on these files
and have the program launch AND load the contents of the clicked file.
I have been able to do the first half.  I can click on a .pcfs file and
the program comes up.  But how do I make the program "see" the clicked
file and load it?

I'm not even sure what this action is called, and so I haven't found
any resources on an internet search.  Anybody know how to do this?

Thanks in advance.

Author
25 Jan 2006 11:23 PM
Herfried K. Wagner [MVP]
"bidalah" <bida***@yahoo.com> schrieb:
> I have created a program which opens up ".pcfs" files, a kind of text
> file unique to my program.  I want to be able to click on these files
> and have the program launch AND load the contents of the clicked file.
> I have been able to do the first half.  I can click on a .pcfs file and
> the program comes up.  But how do I make the program "see" the clicked
> file and load it?

Add the code below to an empty ".vb" file, then select 'Sub Main' as startup
object in the project properties.  'OpenFile' can be replaced with your
logic used to open and display the file's content.

\\\
Public Module Program
    Public Function Main(ByVal Args() As String) As Integer
        If Args.Length > 0 Then
            OpenFile(Args(0))
        End If
    End Function
End Module
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
25 Jan 2006 11:25 PM
Chris
bidalah wrote:
Show quoteHide quote
> Hi,
>
> I have created a program which opens up ".pcfs" files, a kind of text
> file unique to my program.  I want to be able to click on these files
> and have the program launch AND load the contents of the clicked file.
> I have been able to do the first half.  I can click on a .pcfs file and
> the program comes up.  But how do I make the program "see" the clicked
> file and load it?
>
> I'm not even sure what this action is called, and so I haven't found
> any resources on an internet search.  Anybody know how to do this?
>
> Thanks in advance.
>

You need to look at the command line arguments when your program
launches.  The filename and path will be passed in that way.  So you
just have a function to open the file when it sees a file.  Do a search
on "vb.net commandline arguments" and you'll get a lot of examples.