|
-
Jan 5th, 2008, 02:06 PM
#1
Thread Starter
Lively Member
[2005] Open your program by opening a file
Well this is my question:
With my program i created a file. Example: file.myE(xtention)
Now ill tell windows that all the *.myE must be opend by my own programm: iOpenYou.exe.
How do i tell in my program wich method i must call when windows is sending that file to my .exe? I know that in Java it is the contructor Main(args[] as string) and you can extract the filename from args[].
But can i do this in VB.net?
Greets
-
Jan 5th, 2008, 02:10 PM
#2
Re: [2005] Open your program by opening a file
You will want to create a File Association. This is when you associate a file extension with a default program. So when you double click a file with that extension it will open with the specified program.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 5th, 2008, 02:14 PM
#3
Thread Starter
Lively Member
Re: [2005] Open your program by opening a file
Yes thats correct and how i must program what to do with the file.
Like is there a standard method called OpenWhenProgStarts(filename as string) or something? What i must do in my code to use that file(i know how to work with streams(readers/writers) etc. (or with more file names)
-
Jan 5th, 2008, 03:21 PM
#4
Re: [2005] Open your program by opening a file
what type of file is it?
what would you do with the file if you opened it from within the program, instead of the program being started because you've chose to run the file?
it is possible to use the main sub with args in vb.net
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 5th, 2008, 03:51 PM
#5
Re: [2005] Open your program by opening a file
You would do it with the File Types editor in your setup project for deployment.
http://msdn2.microsoft.com/en-us/lib...k6(VS.80).aspx
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 5th, 2008, 07:24 PM
#6
Thread Starter
Lively Member
Re: [2005] Open your program by opening a file
 Originally Posted by .paul.
what type of file is it?
what would you do with the file if you opened it from within the program, instead of the program being started because you've chose to run the file?
it is possible to use the main sub with args in vb.net
I would do exactly the same when i open the file inside my program.
And it doesnt matter what file type it is. I just want to know how to do it, even when its just plain text shown in a message box and after that close the program when i open that file.
How to use this Main sub with args[] in vb.net?
Greets
-
Jan 5th, 2008, 07:34 PM
#7
Re: [2005] Open your program by opening a file
Using the Args in the Main wont make it so that when you double click on your file extension it will open in your app.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 5th, 2008, 09:40 PM
#8
Thread Starter
Lively Member
Re: [2005] Open your program by opening a file
Then what is ?
-
Jan 5th, 2008, 11:18 PM
#9
Re: [2005] Open your program by opening a file
See the link I posted in #5.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 6th, 2008, 12:38 AM
#10
Re: [2005] Open your program by opening a file
 Originally Posted by RobDog888
See the link I posted in #5. 
what about for debugging + testing it?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 6th, 2008, 04:14 AM
#11
Re: [2005] Open your program by opening a file
For testing you should use Virtual PC 2007. Then you can install / uninstall til the cows come home without affecting your system install.
To view your settings for file types just click (within the Setup project) View > File Types
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 6th, 2008, 10:53 AM
#12
Thread Starter
Lively Member
Re: [2005] Open your program by opening a file
Well doeing it with a setup project is an other story.
On that link you gave me there is no sample code or module i need to reference to or something like that.
All i need to know is what code i need to write within my project to do this.
Ill ask my question in an other way then:
I have a file called: my.msgbox and an .exe called show.exe.
When i drag my.msgbox to my show.exe which method i need to implement or what code i need to show the the text(that is inside my.msgbox) in a message box.
Deploying with a setup will be the next step but first i want to know this.
(Maybe it can be found on that link but i cant)
Greets
-
Jan 6th, 2008, 11:07 AM
#13
Thread Starter
Lively Member
Re: [2005] Open your program by opening a file
Ok i found it.
It was very simple ^^.
vb Code:
Public Module File_assosiation ' (this is your exe name)
Public Sub Main(ByVal args() As String)
If args.Length > 0 Then
MsgBox(args(0))
Else
MsgBox("no file")
'System.Diagnostics.Process.Start(args(0))
End If
End Sub
End Module
So thnx for helo anyway 
Greets
-
Jan 6th, 2008, 03:04 PM
#14
Re: [2005] Open your program by opening a file
 Originally Posted by ovanwijk
Ok i found it.
It was very simple ^^.
vb Code:
Public Module File_assosiation ' (this is your exe name) Public Sub Main(ByVal args() As String) If args.Length > 0 Then MsgBox(args(0)) Else MsgBox("no file") 'System.Diagnostics.Process.Start(args(0)) End If End Sub End Module
So thnx for helo anyway
Greets
You can forget all that, use this:
Code:
Dim Args() As String = Environment.GetCommandLineArgs
For Each Arg As String In Args
'I usually use a SELECT CASE here, forcing Arg to be all lower case
Next Arg
This code can be used anywhere in the project, even the Load event of your startup form, this way you don't have to use a Sub Main, if you don't want to
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|