Results 1 to 7 of 7

Thread: [RESOLVED] [2005] "myapp://"

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Resolved [RESOLVED] [2005] "myapp://"

    Im writing a networked application and want to add some customize by adding a handler like myapp:// (http://, ftp://)

    And be able to pass the arguments to my app like: myapp://IP:Port/Username&Password

    I bet I could find some tutorial about it on the internet, but I really don't know what the name of it would be.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] "myapp://"

    Are you talking about passing arguments to your app on the command line, when you actually start it?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Lively Member
    Join Date
    Jul 2006
    Posts
    105

    Re: [2005] "myapp://"

    im not sure 100% what you want but
    vb.net Code:
    1. Public Function App_Path() As String
    2.         Return System.AppDomain.CurrentDomain.BaseDirectory()
    3.     End Function

    would return the path of the application

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Re: [2005] "myapp://"

    Kinda

    Programs like Steam (Valve Software), Teamspeak, most games, etc allow you to pass arguments via your browser or Windows Explorer like:

    myApp://Argument1:Argument2/Agrument3&Argument4

    via the browser's address bar.

    Another example:
    Teamspeak, which is a network voice program lets you start the application and pass arguments like this:
    teamspeak://127.0.0.1:8001/nickname=Test?loginname=Test1?password=Test2?channel=Test3?channelpassword=Test4

    Basically its like http://, ftp://

  5. #5
    Lively Member Divine's Avatar
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    68

    Re: [2005] "myapp://"

    Hmmm, this is my solution.

    Let's say it's a textbox and you click on a button to pass the command (or you can check the keycode in the KeyDown event for the [Enter] key if you want it to be more like a console app).

    Let's say this is what a code could look like:

    Code:
    MyApp://127.0.0.1:8001/name=Test?password=Bob
    I will split this into 3 sections with A = "MyApp", B = "127.0.0.1:8001", and C = "name=Test?password=Bob". Pretend that the maximum number of commands in part C is 5.

    I added some sample code to demonstrate each step. You'll have to declare your own variables though.

    1. Set a string variable to equal the entered text in the textbox. This will be called Cmd.
    Cmd = TextBox1.Text

    2. Set an integer variable to equal the index of "://" in Cmd. I'll call the variable i1.
    i1 = Cmd.IndexOf("://")

    3. Then set another string (called A) to equal the substring of Cmd with the starting character parameter as 0 and the length parameter equal to i1 (the fact that i1 is actually equal to the position of ":" cancels out the need to add 1 for zero-based indexing). A now equals "MyApp".
    A = Cmd.Substring(0,i1)

    4. Now use an If statement to make sure that A = "MyApp" (otherwise discontinue and report it as incorrect syntax).
    If A = "MyApp" Then
    'Do nothing, this is correct
    Else
    MsgBox("Incorrect Syntax!")
    Return
    End If

    5. Now set Cmd to equal the substring of itself with the starting parameter as i1 + 3 (once again because i1 is the index of the colon in ://). Don't specify a length (automatically gets the whole length of the string).
    Cmd = Cmd.Substring(i1+3)

    6. Now set an integer called i2 to equal the index of "/" in Cmd.
    i2 = Cmd.IndexOf("/")

    7. Set a string called B to equal the substring of Cmd with starting parameter as 0 and the length parameter as i2. B now equals "127.0.0.1:8001".
    B = Cmd.Substring(0,i2)

    8. Set Cmd to equal the substring of itself with the starting parameter as i2 + 1 (because i2 is the index of the slash). Again, don't specify a length.
    Cmd = Cmd.Substring(i2+1)

    9. Set i3 to equal the index of "?" in command.
    i3 = Cmd.IndexOf("?")

    10. Check to make sure that i3 is not -1. (in case there is no question mark)
    If i3 = -1 Then
    username = Cmd
    Return
    End If

    11. Set C equal to the substring of Cmd with the starting parameter as 0 and the length as i3. C is now equal to "name=Test"
    C = Cmd.Substring(0,i3)

    13. Make a counting variable to tell how many question marks are within the original command.
    Dim count as Integer = 0

    14. Now make a loop so that it keeps reading the text until there are no more question marks (followed by a command) to read.
    vb Code:
    1. Cmd = Cmd.Substring(i3 + 1)
    2. i3 = Cmd.IndexOf("?")
    3. While Not i3 = -1 Or count < 6
    4.    count = count + 1
    5.    C = Cmd.Substring(0,i3)
    6.  
    7.    'Now make a case statement to check for which question mark this is
    8.    '[Pseudocode]
    9.    'Case of count
    10.    'In the case: count = 2
    11.    'password = C
    12.    'In the case: count = 3
    13.    'servername = C
    14.    'In the case: count = 4
    15.    'serverip = C
    16.    'and so on...
    17.  
    18.    Cmd = Cmd.Substring(i3+1)
    19.    i3 = Cmd.IndexOf("?")
    20. End While
    15. Before all of this when you declare username, password, servername, serverip, etc, you should set default values for each of them in case they are not changed by this code.

    I hope this helps,
    ~Divine
    Last edited by Divine; Jan 22nd, 2008 at 07:42 PM.
    "He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever."

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2005
    Location
    Alaska
    Posts
    435

    Re: [2005] "myapp://"

    Okay, I found what it's called: UriParser

    http://jasonkemp.ca/archive/2005/11/14/2758.aspx

    Looks like Microsoft made it easy too

  7. #7
    Lively Member Divine's Avatar
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    68

    Re: [2005] "myapp://"

    Quote Originally Posted by tylerm
    Okay, I found what it's called: UriParser

    http://jasonkemp.ca/archive/2005/11/14/2758.aspx

    Looks like Microsoft made it easy too
    Well yeah, there are tons ActiveX controls for VB/VB.Net ranging from fixing vertical tabs to new color dialogs. Lots of the good ones aren't free though and can be as much as several hundreds of dollars.

    I just wanted to show you the code . I think external add-ons can sometimes ruin the fun of programming. That's actually the reason I like programming so much: Coming by a hard challenge, devising an algorithm, optimizing it, then running what I wrote and enjoying it. If I use something I didn't write myself...well, it just doesn't give me the same feeling.
    "He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width