如何打开文件(比如说.html文件)并将其加载到WinForm应用程序的WebBrowser控件中?我正在谈论右键单击该文件并选择使用我的应用程序打开它。有什么想法吗?
答案 0 :(得分:2)
您可以将其作为命令行参数传递。在应用程序中,您应该分析命令行参数并将文件加载到WebBrowser中。
答案 1 :(得分:0)
我从来没有在Windows中预先填充Open With菜单,我总是手动添加新项目。
如果你想创建一个完整的关联,这里有一些代码:
Public Sub associate(EXT As String, FileType As String, _
FileName As String)
On Error Resume Next
Dim b As Object
Set b = CreateObject("wscript.shell")
b.regwrite "HKCR\" & EXT & "\", FileType
b.regwrite "HKCR\" & FileType & "\", "MY file"
b.regwrite "HKCR\" & FileType & "\DefaultIcon\", FileName
b.regwrite "HKCR\" & FileType & "\shell\open\command\", _
FileName & " %L"
b.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\Application"
b.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\Application", FileName
b.regdelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\OpenWithList\"
b.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\" & EXT & "\OpenWithList\a", FileName
End Sub
(对不起VB,它是从interwebs偷来的)
答案 2 :(得分:0)