Questions? Search our site or call us at 1-800-722-6004

Detecting if WinWedge is Running from a VB Program

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

Categories: Macro / Code Sample, Visual Basic 6.0, C/C++, .NET, Data Collection, Serial (RS232), WinWedge

Last Updated: 2013.08.30

Need more help?

Don't hesitate to call or email us with your questions

Our office is open 9AM - 5PM Monday Through Friday (E.S.T.)

Technical Support: 215-496-0202

Toll-Free: 1 (800) 722-6004
Skype: taltech1 (Voice only)
Email: support@TALtech.com