用cmd 打开文件:
shell "cmd.exe /c start "+chr(34)+chr(34)+" "+chr(34)+"你的文件路径"+chr(34),vbhide
有效防止shell打不开除exe以外格式的程序。
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_SHOWNORMAL = 1
打开:
ShellExecute 0, "open", "c:\1.txt", "", vbNullString, SW_SHOWNORMAL
"c:\1.txt", ""
分别为文件路径和执行参数(一般是exe)
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_SHOW = 5
Private Sub Command1_Click()
Dim strFloder As String
strFloder ="打开文件的路径(只用输到不包含文件名的路径。例如C:\1.txt.只用输“C:\”就可以了。)"
ShellExecute Me.hwnd, "open", "打开文件的文件名", 0, strFloder, SW_SHOW
End Sub
做程序的是不是都太复杂了,是不是可以直接shell“粘贴exe程序源地址”,是不是就好了,那么复杂,但是移动了源文件,这个命令就失效了