Advertisement
CorrM

URI Schemes In VB.Net

Oct 25th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.51 KB | None | 0 0
  1. ' ---------------------
  2. ' Coded By CorrM
  3. ' It's [ Require Administrator Access ]
  4. ' ---------------------
  5. '
  6. ' Use Example
  7. Dim URI_Schemes As New URI_Schemes
  8. With URI_Schemes
  9.     .Protocol_Name = "CorrM"
  10.     .exe_Path = Application.ExecutablePath
  11.     .Create()
  12. End With
  13.  
  14. ' In Form Load You Can Use This Code
  15. MsgBox(Uri.UnescapeDataString(Environment.GetCommandLineArgs()(1)))
  16.  
  17. ' In Browser Go To
  18. ' CorrM:My Name Is CorrM
  19.  
  20. ' Or In HTML You Can Use This Code
  21. ' <a href="corrm:My Name Is CorrM">Click Here</a>
  22.  
  23. '
  24. ' ---------------------
  25.  
  26.  
  27. Public Class URI_Schemes
  28.  
  29.     Dim _Protocol_Name As String
  30.     Public Property Protocol_Name As String
  31.         Get
  32.             Return _Protocol_Name
  33.         End Get
  34.         Set(value As String)
  35.             _Protocol_Name = value
  36.         End Set
  37.     End Property
  38.  
  39.     Dim _exe_Path As String = Application.ExecutablePath
  40.     Public Property exe_Path As String
  41.         Get
  42.             Return _exe_Path
  43.         End Get
  44.         Set(value As String)
  45.             _exe_Path = value
  46.         End Set
  47.     End Property
  48.  
  49.     Sub Create()
  50.         With My.Computer.Registry.ClassesRoot.CreateSubKey(_Protocol_Name)
  51.             .SetValue("", "URL:" & _Protocol_Name & " Protocol")
  52.             .SetValue("URL Protocol", "")
  53.             .CreateSubKey("DefaultIcon").SetValue("", _exe_Path)
  54.             .CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command").SetValue("", Chr(34) & _exe_Path & Chr(34) & " " & Chr(34) & "%1" & Chr(34))
  55.         End With
  56.     End Sub
  57.  
  58. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement