FileListBox双击打开文件

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:17:39
现在FileListBox中显示出来的文件
如:
1.exe
2.exe
3.exe
我想要选中并双击就能打开相应的文件的代码怎么写?

Private Sub File1_Click()
STK = Dir1.Path & "\" & File1.FileName
Text1.Text = STK
End Sub

Private Sub File1_DblClick()
ShellExecute hwnd, "open", STK, vbNullString, vbNullString, 1

End Sub

ShellExecute需要先声明函数
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