Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21847

Help Needed Converting VB6 OpenProcess to .Net - Process Execution Speed

$
0
0
I am trying to convert an application from VB6 to VB.net which essentially deploys windows images in a WinPE environment. We are moving from VB6 WinPE 3.0 x86 to VB.Net WinPE 4.0 x64 and our imaging application needs to be upgraded accordingly. The majority of coding is done, but there is an issue regarding speed of image deployment that I cannot seem to find the answer to.

The VB6 code deploys images via calling ghost32.exe and passing it some start-up parameters. Essentially this is just the ghost image file location and several other constants. Firstly I thought there could be any number of differences between WinPE 3.0 and 4.0, x86 and x64 and even VB6 to Vb.net. However, when I manually input the command string into shell in the old existing environment the speed is also slow. So I need to understand why when executed via the old Vb6 code does the deployment speed almost double.

Any help would be appreciated :)


Code:

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 Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
   
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
   
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'END WINDOWS

The basic sub is :
Code:

       
 If FileExists("V:\Install1.GHO") = True Then
            frmSplash.lbl_progress.Caption = "Deploying test image..."
            lngTaskID = Shell("X:\Windows\System32\ghost32.exe -clone,mode=restore,src=""V:\Install1.GHO"",dst=1 -sure", vbMinimizedNoFocus)
                Do
                lngPID = OpenProcess(PROCESS_QUERY_INFORMATION, False, lngTaskID)
                DoEvents
                CloseHandle lngPID
              Loop Until lngPID = 0
              Call createReport
               
                If bPass = False Then
                    erri = MsgBox("MODEL SERIAL FAILED" & vbCr & "PLEASE CHECK MODEL/SERIAL/ASSET IN BIOS", vbCritical, "MODEL/SERIAL/ASSET ERROR!")
                   
                    lngTaskID = Shell("X:\Windows\System32\wpeutil.exe shutdown", vbHide)
                  Do
                    lngPID = OpenProcess(PROCESS_QUERY_INFORMATION, False, lngTaskID)
                    DoEvents
                    CloseHandle lngPID
                  Loop Until lngPID = 0
               
                End If
               
                erri = MsgBox("Test image deployed. Click OK to restart", vbOKCancel)
               
                If erri = vbOK Then
                  lngTaskID = Shell("X:\Windows\System32\wpeutil.exe reboot", vbHide)
                  Do
                    lngPID = OpenProcess(PROCESS_QUERY_INFORMATION, False, lngTaskID)
                    DoEvents
                    CloseHandle lngPID
                  Loop Until lngPID = 0
                Else
                    Unload frmSplash
                    Exit Sub
                End If
        End If


Viewing all articles
Browse latest Browse all 21847

Trending Articles