What is the VB 6 equivalent of Process.Start?

前端 未结 3 1413
星月不相逢
星月不相逢 2021-01-14 13:19

I am stuck on a really stuck with this one line. In vb.net this is easy, but how do I do this in vb6? Tried to search from google for few hours and got nothing. Feels almost

相关标签:
3条回答
  • 2021-01-14 14:01

    You can use Shell and ShellExecute

    Shell "c:\runme.exe", vbNormalFocus
    

    http://msdn.microsoft.com/en-us/library/aa242087(v=vs.60).aspx

    0 讨论(0)
  • 2021-01-14 14:11

    Just call Shell, and the parameters should be passed also with the string of the .exe name, like this:

    Call Shell("""runme.exe"" ""-parameter1 "" ""-parameter2""", vbNormalFocus)
    

    PS: The quotes make the difference, dont ignore it :)

    0 讨论(0)
  • 2021-01-14 14:15

    You can use ShellExecute for this:

    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", App.Path & "\runme.exe", "-parameter1 -parameter2 -parameter3", vbNullString, vbNormalFocus 
    

    I have found that using Shell causes a delay in the calling program waiting for the return value, whereas ShellExecute does not.

    0 讨论(0)
提交回复
热议问题