Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having to install some support files from within a VB6 application by using a shell. I am using the code below so send the command for the install. Is there a way to integrate in Doevents by using something other than WaitForSingleObject so the application would be responsive, at least not showing "Not Responding"?

Thanks
VB
Public Function ShellSync( _
    ByVal PathName As String, _
    ByVal WindowStyle As VbAppWinStyle) As Long
    'Shell and wait.  Return exit code result, raise an
    'exception on any error.
    Dim lngPid As Long
    Dim lngHandle As Long
    Dim lngExitCode As Long

    lngPid = Shell(PathName, WindowStyle)
    If lngPid <> 0 Then
        lngHandle = OpenProcess(SYNCHRONIZE _
                             Or PROCESS_QUERY_INFORMATION, 0, lngPid)
        If lngHandle <> 0 Then
            WaitForSingleObject lngHandle, INFINITE
            If GetExitCodeProcess(lngHandle, lngExitCode) <> 0 Then
                ShellSync = lngExitCode
                CloseHandle lngHandle
            Else
                CloseHandle lngHandle
                Err.Raise &H8004AA00, "ShellSync", _
                          "Failed to retrieve exit code, error " _
                        & CStr(Err.LastDllError)
            End If
        Else
            Err.Raise &H8004AA01, "ShellSync", _
                      "Failed to open child process"
        End If
    Else
        Err.Raise &H8004AA02, "ShellSync", _
                  "Failed to Shell child process"
    End If
End Function
Posted
Updated 7-Aug-13 9:42am
v4
Comments
Sergey Alexandrovich Kryukov 7-Aug-13 16:45pm    
Anything except getting rid of VB6 is just no serious. You really need multithreading, to start with. Any particular reason to deal with VB6?
—SA
onemorecoke 7-Aug-13 16:55pm    
It's a long story,but here it goes. I did not want to use a purchased installer like InstallShield because they are too much money and wont do everything I need. I created a WinRAR self-extracting EXE for my install, but then I needed a small program to do all the configuration involved. Part of the problem with using .NET for the install program is that the .NET Framework may not be on the computer so it would not run. With VB6, it is almost guaranteed that it will run because the runtime has been in the OSs for quite some time. It works great on all machines now, with the only problem being that when I load .Net Framework 4.5 the VB6 form can show "not responding", and i would like to get rid of that. Thanks for looking.
Sergey Alexandrovich Kryukov 7-Aug-13 17:03pm    
Rare thing could be worse or more destructive than VB6.
As to the setup, I strongly recommend WiX. Do you understand that, compared to Wix, InstallShield is nearly illegal? WiX is open source and provide full compliance with MSBuild, its project type (and available VS template and add-on, by the way) is the valid standard MSBuild project.
—SA

1 solution

You can use WshShell.Run. It is not freeze if you wait the child process.

WshShell.Run
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900