12-11-2009, 12:49 AM
(This post was last modified: 12-11-2009, 12:53 AM by thanasis2028.)
(12-10-2009, 09:26 AM)Nonmod Wrote: if vb.net is c#-like ,search for main entry point for your program(in c# its Main()),smth like that.Ok, it was rather different but after a lot of search I found it.
The trick is-when you doubleclick a file,windows instantly sends this file path to associated application as variable named %1.
If you know where is you app's entry point,=, add a argument to that function-may be smth like Main(eventargs e).
When you find it,put there simple if statement.here's pseudocode:
Code:if strFilePath != null
do something with file
else
open app w/o file
The 2nd parameter of the app is the file opened. So, here is the code:
Code:
'Next code will find if a .mvt was opened
Dim s() As String = System.Environment.GetCommandLineArgs()'finds parameters and stores it to a string array
Try
If InStr(s(1), ".mvt") = s(1).Length - 3 Then 's(1) is the file that was opened
'open file 'InStr(s(1), ".mvt") = s(1).Length - 3 checks if file has our extension (.mvt)
End If
Catch ex As Exception
'.exe was opened directly and s(1) does not exist
End Try