他的範例是寫入機碼,如果您是要txt的話,如下,
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
您可以看一下機碼的對應,如下,


原來是[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.txt\UserChoice]在亂事 |