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

相似于一个快捷方式。是exe程序,不是TXT文档
2024-12-21 22:19:49
推荐回答(4个)
回答1:

如果你是想要打开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

回答2:

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,只要在资源管理器中能显示有图标的文件都能打开

回答3:

代码关键字好像是shell。

回答4:

呵呵,不会是拿来使用在不良目的上啊?