+ -
当前位置:首页 → 问答吧 → VB如何快速运行外部程序

VB如何快速运行外部程序

时间:2011-07-16

来源:互联网

发现用SHELL或者SHELLEXECUTE都好,运行一个外部程序起码需要三秒才能打开,但直接运行一秒左右就行了.为什么会差那么多,有什么方法能够快一些运行呢?

作者: penguinhzf   发布时间: 2011-07-16

Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long
Private Const SW_RESTORE = 9
 


Private Sub cmdCommand1_Click()
Dim RET As Integer
RET = WinExec("CALC.EXE", SW_RESTORE)
'Shell "CALC.EXE,1" '利用SHELL将弹出“文件未找到”的错误信息
If RET > 32 Then Print "调用正确" Else Print "调用错误"
 
End Sub

Private Sub cmdCommand2_Click()
End
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
 
Private Sub Command1_Click()
Dim RET As Integer
RET = ShellExecute(Me.hwnd, "open", "winword.EXE", "", 1, 5)
'Shell "winword.EXE,1" '利用SHELL将弹出“文件未找到”的错误信息
If RET = 0 Then Print "调用错误" Else Print "调用正确"
End Sub
 
Private Sub Command2_Click()
End
End Sub

作者: robote2   发布时间: 2011-07-17

热门下载

更多