locked
Work with 'Windows open with'. RRS feed

  • Question

  • I created source code (HTML) Editing software. After installing it on windows it does not shows the syntax , when opened a file using right click and open with my software. What is the code to solve this?
    Saturday, December 29, 2012 7:03 AM

Answers

  • When you right click a file and select Open With, and you open it with a program, the file path is passed to the program as an argument. You can use this argument to load the file.

    Here is a screenshot of what happens:

    Screenshot illustration

    Use the Command() function to get all arguments passed to your application.

    Here's an example:

        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim startupParams As String = Command()
    
            'Verify that it's not empty
            If Not String.IsNullOrWhiteSpace(startupParams) Then
    
                'Trim unneccessay spaces and quotation marks.
                startupParams = startupParams.Trim({" "c, """"c})
    
                'Verify that it is a valid filename and that the file exists.
                If IO.File.Exists(startupParams) Then
    
                    'Load the file.
                    TextBox1.Text = My.Computer.FileSystem.ReadAllText(startupParams)
    
                End If
            End If
        End Sub

    Hope it helps.

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    • Edited by bilde2910 Monday, December 31, 2012 1:06 PM Fixed the illustration.
    • Marked as answer by -PD- Saturday, January 5, 2013 1:34 PM
    Monday, December 31, 2012 12:52 PM

All replies

  • Are you trying to get windows to always open a file of a certain type using your software?

    You've taught me everything I know but not everything you know.

    Saturday, December 29, 2012 7:13 AM
  • Hi PD,

    Please ask your question in a specific way.

    We don't know what the "source code (HTML) Editing software" is, also don't know what you mean "it does not shows the syntax".

    So NO one can give you the code for solution.


    No code, No fact.

    Monday, December 31, 2012 8:11 AM
  • When you right click a file and select Open With, and you open it with a program, the file path is passed to the program as an argument. You can use this argument to load the file.

    Here is a screenshot of what happens:

    Screenshot illustration

    Use the Command() function to get all arguments passed to your application.

    Here's an example:

        Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            Dim startupParams As String = Command()
    
            'Verify that it's not empty
            If Not String.IsNullOrWhiteSpace(startupParams) Then
    
                'Trim unneccessay spaces and quotation marks.
                startupParams = startupParams.Trim({" "c, """"c})
    
                'Verify that it is a valid filename and that the file exists.
                If IO.File.Exists(startupParams) Then
    
                    'Load the file.
                    TextBox1.Text = My.Computer.FileSystem.ReadAllText(startupParams)
    
                End If
            End If
        End Sub

    Hope it helps.

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    • Edited by bilde2910 Monday, December 31, 2012 1:06 PM Fixed the illustration.
    • Marked as answer by -PD- Saturday, January 5, 2013 1:34 PM
    Monday, December 31, 2012 12:52 PM
  • Thank you!!!
    Saturday, January 5, 2013 1:38 PM
  • Thank you!!!

    You're very welcome :)

    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    Saturday, January 5, 2013 9:20 PM