-
VB Setup Projects File Associations, Port communication, & the .NET compact framework
Hello,
I have recently acquired the Visual Basic .NET 2003 software (to begin programming, I went through the Visual Basic .NET Step by Step book), and have some questions about VB .NET programming that I could not find answers to in the help files. If anyone can answer these questions, some samples in code would be very helpful too. The questions are:
1. VB Setup Projects File Associations: I have been trying to create file associations (using a setup project) so that when a file is opened via Windows Explorer (say a text file: file1.txt) it will start with my program and the program will show the file chosen. The trouble I am having is that I can't find out how to make the program recognise and open the file selected in Explorer. The only thing that happens when I double click a file is that my program starts, but without showing the file. I think this is something to do with Actions, but where do I put the code, and how do I make it open the file selected??? Basically, what do I do?
Here are the other questions:
2. Port communication: Is there any way to communicate directly with ports (i.e.. the sockets at the back of the computer) that is not too complicated (like I think writing driver software would be)? I am thinking of making an electronic device to be controlled by the computer, so no current software would recognise it.
3. .NET Compact framework: Would the .NET compact framework be suitable for desktop computers where installation size is important? If so, how do I obtain it (for redistribution)?
If this is not descriptive enough, please tell me what else you need to know. I have tried many people, but nobody has been able to help.
Thank you for your assistance.
VBDever
Last edited by VBDever; 08-16-2005 at 03:33 AM.
-
You can create a Setup and Deployment Project to create a file association:
http://msdn.microsoft.com/library/de...pplication.asp
Regarding port communication see the following:
http://www.microsoft.com/downloads/d...DisplayLang=en
The Compact Framework is for .NET applications that run on mobile devices.
Paul
~~~~
Microsoft MVP (Visual Basic)
-
More information on your first question: When you launch an app via an associated file, the file name(s) are passed to your application as command line parameters. See the following article for details on how to process these parameters: http://www.devx.com/dotnet/Article/10115
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Console vs. Windows Forms File association
I have got File associations working with Console Applications, but when I try using Command() in the Windows Forms enviroment I get the following error message:
'System.Windows.Forms.Command' is not available in this context because it is 'Private'.
Code:
'This is the code I typed above the 'Windows Forms Designer Generated Code' Region
'of Form1 (the startup form)
Dim filename As String = Command()
Do you know how to get Command() (or it's equivelant) to work with Windows forms?
Sincerely,
VBDever
-
Command() is a function, so it must be used within a method (a Sub or a Function). It sounds like you're trying to use it outside a method.
Another option is to start your application with a Sub Main, which may optionally receive command line parameters as an array:
Code:
Sub Main(ByVal args() as String)
For Each FileName As String In args
' Process FileName here
Next
End Sub
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
When I enter that code and choose 'Run', I get the following build error:
No accessable 'Main' method with appropriate signature was found.
I tried making a Main() function (below), but it still had the same error!
Code:
Public Sub Main()
End Sub
Sincerely,
VBDever
-
Try looking up "Sub Main" in VB's online help. Or look in your "Step-By-Step" book; doesn't it mention Sub Main?
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
All working now!
Thanks, everything is working now, I put Sub Main() in a seperate module and set the startup object of my project to Sub Main.
Sincerely,
VBDever
-
Similar Threads
-
By cooldude.i2k in forum VB Classic
Replies: 3
Last Post: 08-05-2005, 03:13 AM
-
By ssun in forum VB Classic
Replies: 1
Last Post: 07-22-2005, 02:20 PM
-
By Pon Thiagarajan TS in forum VB Classic
Replies: 2
Last Post: 02-14-2001, 09:31 PM
-
By Pon Thiagarajan TS in forum VB Classic
Replies: 0
Last Post: 02-14-2001, 11:04 AM
-
By Vla in forum VB Classic
Replies: 1
Last Post: 11-23-2000, 12:48 AM
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
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|