|
-
Aug 28th, 2000, 12:10 PM
#1
Thread Starter
Lively Member
Hi guys...
Im using a Kernal32 call to pause one of my programs and make it wait until another program finishes... I need to know an NT equivlant to do the same thing... NT 4 service pack 4...
Thanks in advance
Brooke
-------------------------
There is never only one right answer. That is the magic of programming.
-------------------------
-
Aug 28th, 2000, 12:22 PM
#2
Addicted Member
Hmm, try lookin through Win23api.txt with Apiloader that is usually in devstudio\vb\win32api. You should find something. Hope it helps
-
Aug 28th, 2000, 01:37 PM
#3
Fanatic Member
What function of kernel32.dll do you call?
-
Aug 28th, 2000, 02:32 PM
#4
Thread Starter
Lively Member
Here is the pause program routine
Private fs As New FileSystemObject
Private txtFile As File
Private ts As TextStream
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 CreateProcessA Lib "kernel32" (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 Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
Public Tp_Cd As String
Sub Main()
'dimension variables to hold sql statements to sort the data by TP code
Call sortTPcd
End
End Sub
Function sortTPcd()
Dim strTempTPCD, strInputFile, strOutputFile, strLine As String
strInputFile = "H:\multipletp.txt"
strOutputFile = "H:\inbProductActivity.txt"
Tp_Cd = ""
Open strInputFile For Binary As #1
Open strOutputFile For Output As #2
Do While Not EOF(1)
On Error Resume Next
Line Input #1, strLine ' read line into variable.
Debug.Print strLine
If Tp_Cd = "" Then
Tp_Cd = Mid(strLine, 9, 20)
Debug.Print Tp_Cd
End If
If Mid(strLine, 9, 20) = Tp_Cd Then
Print #2, strLine 'write line to inbProductActivity.txt
Else
Close #2
'pause program and run Prod_Act_Data.
command1_Click
Open strOutputFile For Output As #2
Tp_Cd = Mid(strLine, 9, 20)
Print #2, strLine 'write line(next tpcd) to inbProductActivity.txt
End If
Loop
Close 'closes #1 and # 2
'pause program and run Prod_Act_data for final TPCD
command1_Click
'Kill strInputFile
MsgBox "Sort & Process 852 is Finished"
End
End Function
Public Function ExecCmd(cmdline$)
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
' Initialize the STARTUPINFO structure:
start.cb = Len(start)
' Start the shelled application:
ret& = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
' Wait for the shelled application to finish:
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call GetExitCodeProcess(proc.hProcess, ret&)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ExecCmd = ret&
End Function
Sub command1_Click()
Dim retval As Long
retval = ExecCmd("\\EDITEST\Inbound\Wake Fern Product_Activity_Data\Run\Prod_Act_Data.exe")
'MsgBox "Process Finished, Exit Code " & retval
End Sub
-------------------------
There is never only one right answer. That is the magic of programming.
-------------------------
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
|