|
-
Aug 28th, 2000, 08:58 AM
#1
Thread Starter
New Member
I need some help. I am writing an application that accesses an external exe file which is a DOS application. I am currently using the shell command to access this file. What this application does is rebuilds the tables in a FairCom Database using a modified version of the standard rebuild function. The problem is when I goto do a rebuild of all the tables I have a Do loop which opens up the rebuild application and gets passed the name of the table. The VB application is basically just a GUI for the DOS application. Here is my sample of code. I hope it explains better what I am trying to do.
Private Sub cmdBegin_Click()
Dim MaxListitem
MaxListitem = cboTableName.ListCount - 1 'Gets the total number of tables in the DB
If chkAllTables.Value = 1 Then 'Checks if the user wants a rebuild of all the tables.
PrgCom.Max = MaxListitem 'Max property for a progress bar
Do Until cboTableName.ListIndex = MaxListitem 'loops through all the tables
Call RunRebuild ' calls the rebuild
cboTableName.ListIndex = cboTableName.ListIndex + 1 'moves to the next table
PrgCom.Value = PrgCom.Value + 1 'increases the progress bar
Loop
Else
RunRebuild ' used if rebuilding only one table
End If
End Sub
____________________________________________________________
Private Sub RunRebuild()
Dim validation As Boolean
Dim NewSting As String
Dim Runrbld As String
Dim Pathtocheck As String
validation = False
Pathtocheck = ""
NewString = "C:\Work\Clin\Util\csrbld.exe" + " C:\Work\Clin\jk_tech " + cboTableName.Text + " >>rebuild.log" ' the path csrbld [schema] [tablename]
Runrbld = Shell(NewString, vbNormalFocus) 'runs the app
Loop
End Sub
____________________________________________________________
Private Sub DisplayLog()
Do Until EOF(1)
Input #1, Outy
txtOutput.Text = txtOutput.Text + Outy + vbCrLf
Loop
End Sub
The problem I am having is that it opens up 130 instances of the database rebuild, one for each table. What I want it to do is wait till the first rebuild is finished to do the second. I need some sort of check, anyone have any idea's.
"Oh damn why does this not work"
"Every computer is a F.R.E.D, Freeking Ridiculous Electronic Device, the first word depending on your level of frustration"
-
Aug 28th, 2000, 09:04 AM
#2
Here you go! Add this code to the form and call the ShellAndWait procedure instead of the normal Shell function.
Code:
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject _
Lib "kernel32" ( _
ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcess _
Lib "kernel32" Alias "CreateProcessA" ( _
ByVal lpApplicationName As Long, _
ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As Long, _
ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, _
ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle _
Lib "kernel32" ( _
ByVal hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Private Const STARTF_USESHOWWINDOW = &H1
Public Sub ShellAndWait(sCmd As String, Optional WindowStyle As VbAppWinStyle = vbNormalFocus)
Dim udtStart As STARTUPINFO
Dim udtProc As PROCESS_INFORMATION
udtStart.cb = Len(udtStart)
udtStart.dwFlags = STARTF_USESHOWWINDOW
udtStart.wShowWindow = WindowStyle
CreateProcess 0&, sCmd, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, udtStart, udtProc
WaitForSingleObject udtProc.hProcess, INFINITE
CloseHandle udtProc.hProcess
AppActivate Me.Caption
End Sub
-
Aug 28th, 2000, 09:33 AM
#3
Thread Starter
New Member
Thank you soooooooooo.... much, that fixed my problem. I can't say thank you enough. If you ever need anything, just email me. [email protected]
Once again Thank You.
"Oh damn why does this not work"
"Every computer is a F.R.E.D, Freeking Ridiculous Electronic Device, the first word depending on your level of frustration"
-
Aug 28th, 2000, 09:36 AM
#4
How about a beer...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|