The following is a sample Visual Basic program that automatically determines if WinWedge is currently active on a serial port. The subroutine should be placed in
the general code section for a form and the form should have a textbox on it named Text1.
Sub FindWedge ()
MaxPorts = 4
' this sub tries to find WinWedge and identify
' the port that it has been activated for
If MyPort$ = "" Then MyPort$ = "COM1": CurrentPort
= 1
On Error GoTo errhandler
TestPort:
text1.LinkMode = 0
text1.LinkTopic = "WinWedge|" + MyPort$
text1.LinkItem = "field(1)"
text1.LinkMode = 3 '=Notify, 1=Hot, 2=Warm
' try to establish a DDE Link to WinWedge
' - this will generate error if wedge is not activated
FindExit:
On Error GoTo 0 ' disable error trap
Exit Sub ' quit
errhandler:
CurrentPort = CurrentPort + 1 ' try next com port
MyPort$ = "COM" + Format$(CurrentPort)
If CurrentPort > MaxPorts Then ' if all ports have been tried
display warning and exit
MsgBox "Cannot Find Software Wedge."
MyPort$ = "": CurrentPort = 0 ' set currentport=0
to indicate that wedge was not found
Resume FindExit
End If
Resume TestPort
End Sub
|