home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Begin VB.Form PyroBatch Caption = "PyroBatch" ClientHeight = 3195 ClientLeft = -165 ClientTop = 135 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 Begin VB.CommandButton Run Caption = "Run PyroBatch Script" Height = 615 Left = 240 TabIndex = 1 Top = 240 Width = 3015 End Begin VB.Label Label1 Caption = "-" Height = 255 Left = 240 TabIndex = 3 Top = 1920 Width = 4095 End Begin VB.Label Label0 Caption = "-" Height = 255 Left = 240 TabIndex = 2 Top = 1440 Width = 3975 End Begin VB.Label Label2 Caption = "Current Command Status:" Height = 255 Left = 240 TabIndex = 0 Top = 1080 Width = 2295 End Attribute VB_Name = "PyroBatch" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False ' define entry point to pyrobatchcontrol.dll Private Declare Function PyroBatch Lib "W:\pyrotrans\pyrobatchcontrol\Debug\pyrobatchcontrol.dll" Alias "_PyroBatch@16" (ByVal lpApp As String, ByVal lpBuffer As String, ByVal lpResult As String, ByVal nSize As Long) As Long Private Sub Run_Click() Dim result As String Dim rc As Integer ' init communication to pyrobatch.exe rc = DoControl("START", result) If rc >= 200 And rc <= 299 Then ' ok rc = DoControl("Connect 'duke', 'test', 'asdf'", result) If rc >= 200 And rc <= 299 Then ' ok, now connected rc = DoControl("LocalChDir 'd:\t'", result) rc = DoControl("Get 'new.mdb'", result) rc = DoControl("Disconnect", result) End If ' terminate communication rc = DoControl("TERM", result) End If 'done End Sub Function DoControl(ByVal command As String, ByRef result As String) As Integer Dim rc As Integer ' return code (200 OK, 300 WARN, 400 PROBLEM, 500 ERROR) Dim pos As Integer ' helper variable Dim app As String ' appname parameter Dim buffer As String * 128 Dim howmany As Long app = "pyrobatch" ' use "pyrobatchftp" for PyroBatchFtp howmany = 128 ' display current command Label0.Caption = command ' exec command and convert result from DLL style to VB rc = PyroBatch(app, command, buffer, howmany) pos = InStr(buffer, Chr(0)) - 1 If pos > 0 Then result = Left(buffer, pos) ' display result string Label1.Caption = result ' process windows message queue For i = 1 To 25 DoEvents Next ' determine result If rc Then rc = Val(Mid(result, 2)) Else rc = 500 ' error End If ' return the return code DoControl = rc End Function