Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.80 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  4.  
  5.         Dim ID As String = CheckForProtocolMessage()
  6.         If Not ID = "N/A" Then
  7.             'do stuff with the id
  8.         End If
  9.  
  10.     End Sub
  11.  
  12.  
  13.     Private Function CheckForProtocolMessage() As String
  14.  
  15.         Dim arguments As String() = Environment.GetCommandLineArgs()
  16.  
  17.         If arguments.Length > 1 Then
  18.  
  19.             'Use this loop tofigure out what the index of the argument you want is after you ge tthat you can take this loop out
  20.             '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  21.             Dim I As Integer = 0
  22.             For Each Str As String In arguments
  23.                 MsgBox("Argument Number : " & I & vbNewLine & "Argument : " & Str)
  24.             Next
  25.             '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  26.  
  27.  
  28.             'The index you find will replace the 1 here
  29.             Dim args As String() = arguments(1).Split(":")
  30.  
  31.             If args(0).Trim().ToLower() = "savesharer" AndAlso args.Length > 1 Then
  32.  
  33.                 Dim actionDetail As String() = args(1).Split("?")
  34.  
  35.                 If actionDetail.Length > 1 Then
  36.                     Select Case actionDetail(0).Trim().ToLower()
  37.                         Case "opensave"
  38.                             Dim details As String() = actionDetail(1).Split("=")
  39.                             If details.Length > 1 Then
  40.                                 Dim id As String = details(1).Trim()
  41.                                 Return id
  42.                             End If
  43.                             Exit Select
  44.                     End Select
  45.                 End If
  46.  
  47.             End If
  48.  
  49.         Else
  50.  
  51.             Return "N/A"
  52.  
  53.         End If
  54.  
  55.     End Function
  56.  
  57. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement