大家帮我看看里面的代码,问题出在哪???

liushiying 2003-10-19 10:42:41
如何双击*.test文件用我的程序打开他,直接运行程序时不打开文件
为什么双击*.test文件时可以正常打开程序
可是为什么不能直接运行程序

Imports Microsoft.Win32
Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

Shared strFile As String

<STAThread()> Shared Sub Main(ByVal CmdArgs() As String)
If CmdArgs.Length = 0 Then
Dim FileExt As String
Dim FileType As String
Dim MIMEType As String
Dim ExecName As String

FileExt = ".test"
FileType = "Test File"
MIMEType = "text/plain"
ExecName = Application.ExecutablePath + " %1"

Dim RegKey As RegistryKey
RegKey = Registry.ClassesRoot
RegKey = RegKey.CreateSubKey(FileExt)
RegKey.SetValue("", FileType)
RegKey.SetValue("Content Type", MIMEType)
RegKey = RegKey.CreateSubKey("shell\open\command")
RegKey.SetValue("", ExecName)
RegKey.Close()
Return
End If
strFile = CmdArgs(0)
System.Windows.Forms.Application.Run(New Form1())
End Sub

Public Sub New()
MyBase.New()

'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
Me.richTextBox1.Dock = DockStyle.Fill
Me.richTextBox1.LoadFile(strFile, RichTextBoxStreamType.PlainText)
End Sub

'窗体重写处置以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer

'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents richTextBox1 As System.Windows.Forms.RichTextBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.richTextBox1 = New System.Windows.Forms.RichTextBox()
Me.SuspendLayout()
'
'richTextBox1
'
Me.richTextBox1.Location = New System.Drawing.Point(40, 40)
Me.richTextBox1.Name = "richTextBox1"
Me.richTextBox1.TabIndex = 1
Me.richTextBox1.Text = "richTextBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(232, 181)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.richTextBox1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

End Class
...全文
29 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Montaque 2003-10-20
  • 打赏
  • 举报
回复
参考
http://expert.csdn.net/Expert/TopicView1.asp?id=2328211

16,553

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧