Private Sub Button1_Click(sender As Object, e As EventArgs)Handles Button1.Click My.Computer.Registry.ClassesRoot.CreateSubKey(".txt").SetValue("","txtfile",Microsoft.Win32.RegistryValueKind.String) My.Computer.Registry.ClassesRoot.CreateSubKey("txtfile\shell\open\command").SetValue("", Application.ExecutablePath &
" ""%l"" ", Microsoft.Win32.RegistryValueKind.String)
End Sub
在Form Load中如果有檔名的話,就取文字檔的內容,如下,
Private Sub Form1_Load(sender As Object, e As EventArgs)Handles MyBase.Load
If(My.Application.CommandLineArgs.Count >0)Then
MsgBox("Hello, "
& My.Computer.FileSystem.ReadAllText(My.Application.CommandLineArgs(0))
&" World!")
End If
End Sub