免費論壇 繁體 | 簡體
Sclub交友聊天~加入聊天室當版主
分享
Board logo

標題: 程式預設開啟 [打印本頁]

作者: mhfo    時間: 2014-2-20 09:06     標題: 程式預設開啟

他的範例是寫入機碼,如果您是要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]在亂事




歡迎光臨 魚骨頭的雲端圖書館 (http://mhfo.hotbbs.info/) Powered by Discuz! 7.0.0