zmanvortex
May 1st, 2002, 08:35 PM
Hi Everyone. I am buidling a VB application which uses DDE via RSLinx to communicate to a processor. I would like to start RSLinx minimized and verify that it is running at my splash screen when my application starts. I was able to start RSLinx using the shell statement in VB with the argument vbMinimized, but RSLinx still started maximized. I would also like to verify that RSLinx is running before leaving my splash screen. I have been unable to find much info on web searches. Hope someone can help.
ganutenator
May 2nd, 2002, 11:55 PM
I am probably speeking too quickly and outside of my knowledge comfort zone but. ..... I was wondering if you couldn't run a shortcut to RSLinx and set the properties on the shortcut to run RSLinx minimized. I tried it only by double clicking on the shortcut, and that worked, or am I missing the point.
lovvornbk
May 3rd, 2002, 10:43 AM
You should have RSlinx set to run as a Service, this will enable it to run in the Systray. Sorry but I do not know of any command line switches will will set this to run minimized.
To check to see if RSlinx is running you can use the following code in VB.
Place this in the General Declartions of a .bas file
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
:::::: Then add these Functions to the .bas file ::::::::
Public Function EnumWindowsProcCallBack(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
Dim RetVal As Long
Dim WinClassBuf As String * 255
Dim WinTitleBuf As String * 255
Dim WinClass As String
Dim WinTitle As String
On Error Resume Next
RetVal = GetClassName(hwnd, WinClassBuf, 255)
WinClass = StripNulls(WinClassBuf) ' remove extra Nulls & spaces
RetVal = GetWindowText(hwnd, WinTitleBuf, 255)
WinTitle = StripNulls(WinTitleBuf)
' see the Windows Class and Title for each top level Window
'Debug.Print WinClass, "::::", WinTitle
'the Following line will check for a specific program
If InStr(WinTitle, sProgram) > 0 Then
bProgramFound = True
'Put code here for info if found
End If
EnumWindowsProcCallBack = True
End Function
Public Function EnumTopLevelWindows()
On Error Resume Next
EnumTopLevelWindows = EnumWindows(AddressOf EnumWindowsProcCallBack, 0)
End Function
Public Function StripNulls(OriginalStr As String) As String
On Error Resume Next
' This removes the extra Nulls so String comparisons will work
If (InStr(OriginalStr, Chr(0)) > 0) Then
OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr(0)) - 1)
End If
StripNulls = OriginalStr
End Function
::::: in you splash form you can then do the following ::::
bProgramFound = False
sProgram = "RSLinx"
Call EnumTopLevelWindows
If bProgramFound = False Then
Call RSlinx
End If
.