VB Setup Projects File Associations + more


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: VB Setup Projects File Associations + more

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Posts
    5

    Question 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 04:33 AM.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    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)

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  4. #4
    Join Date
    Aug 2005
    Posts
    5

    Unhappy 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

  5. #5
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  6. #6
    Join Date
    Aug 2005
    Posts
    5

    Unhappy

    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

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  8. #8
    Join Date
    Aug 2005
    Posts
    5

    Talking 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

  9. #9
    Join Date
    Jul 2009
    Posts
    10

Similar Threads

  1. How to create Setup.exe file given a Vb Project
    By cooldude.i2k in forum VB Classic
    Replies: 3
    Last Post: 08-05-2005, 04:13 AM
  2. modifying xml file with VB
    By ssun in forum VB Classic
    Replies: 1
    Last Post: 07-22-2005, 03:20 PM
  3. Automated print to file from VB
    By Pon Thiagarajan TS in forum VB Classic
    Replies: 2
    Last Post: 02-14-2001, 10:31 PM
  4. Automated print to file from VB
    By Pon Thiagarajan TS in forum VB Classic
    Replies: 0
    Last Post: 02-14-2001, 12:04 PM
  5. How to insert a Text File into VB Projects
    By Vla in forum VB Classic
    Replies: 1
    Last Post: 11-23-2000, 01: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center