怎么用VB6制作一个,当程序一运行,自动打开文件或另一个程序的小程序。

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:16:12
相似于一个快捷方式。
是exe程序,不是TXT文档

如果你是想要打开C:\123.txt文件

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Const SW_NORMAL = 1

Private Sub Command1_Click()
ShellExecute Me.hwnd, "open", C:\123.txt, vbNullString, vbNullString, 1 'c:\123.txt可以换成你想要打开的文件就行..什么格式的文件就自动用相应的程序打开了
End Sub

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute 0,"Open",<你的文件>,"","",1
=========================
这个代码不论是exe还是txt,只要在资源管理器中能显示有图标的文件都能打开