vb调用电脑应用程序打开指定文件

就像电脑打开一个文件一样,可以选择打开方式。
2024-11-02 07:35:46
推荐回答(1个)
回答1:

'下面的api会自动按系统默认程序打开。
Public 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(form.hWnd, "open", "文件含路径", "", "", 1) '
例如:=ShellExecute(form.hWnd, "open", "d:\system\1.txt", "", "", 1) '