Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
vb.net associated files?
#1
I am using VB.net to create an app, and I have associated .mvt files with my application. But how can I tell my app what to do when the user opens(double-clicks) a .mvt file? I need a way for my app to detect that a .mvt was actually double-clicked and not the app itself and read the .mvt that was double-clicked when the app starts. Can you help me ?
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply
#2
(12-10-2009, 05:34 AM)thanasis2028 Wrote: I am using VB.net to create an app, and I have associated .mvt files with my application. But how can I tell my app what to do when the user opens(double-clicks) a .mvt file? I need a way for my app to detect that a .mvt was actually double-clicked and not the app itself and read the .mvt that was double-clicked when the app starts. Can you help me ?

if vb.net is c#-like ,search for main entry point for your program(in c# its Main()),smth like that.
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
Reply
#3
(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.
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
Ok, it was rather different but after a lot of search I found it.
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
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Crypter code source - project files [ vb.net ] rid47 2 2,350 09-08-2012, 04:17 PM
Last Post: spesificrelax
  Need Help with Registering VB Files G1™ 2 818 12-12-2010, 06:24 PM
Last Post: Flamingo

Forum Jump:


Users browsing this thread: 1 Guest(s)