Starting one application after the other application starts.


Thread Starter

Sandeep Shroff

Dear List Members

I have developed a DDE client application which collect information from the DDE Server.

I want to automatically start the application on the computer boot up. So I have created a short cut in the Start-up folder. There is also a
shortcut for the DDE Server in the Start-up. At times it is observed that the DDE server application starts after the Client application is
started. As the server application is not started the client application is generating an error as it doesn't find the server application.

I want to start my DDE client application only after the DDE Server application is started. How can I achieve this on a Windows NT machine. Any suggestion or pointers in this direction would be highly appreciated.

Thanking you in anticipation

Sandeep Shroff
Sr. Consultant
Remote & Embedded Technologies

rapidEffect (P) Ltd. 25, Napier Road, Pune 411001, India
Tel./Fax. +91-20-6363250
Sandeep Shroff:
> I want to start my DDE client application only after the DDE Server
> application is started. How can I achieve this on a Windows NT machine.

The simple way would be to write a batch file (or any other kind of script) that does a "sleep 20" followed by starting your application (I think the command is "start" followed by the pathname).

The proper way would be to use a scripting language with DDE facilities and write a simple loop that repeatedly tries to connect to the server:

repeat 18 times
sleep 10 seconds
try to connect to server
if success
close connection
start client
exit script
end if
clean up connection attempt
end repeat
signal failure of server

Jiri Baum <[email protected]>
MAT LinuxPLC project --- --- Machine Automation Tools

Roland Lilja

Hi Sandeep,
I made a VB aplication with the folloving code. This program is started from "Autostart" and check for the precense of the DDE-server before it starts any other aplications (The programs to be started are listed in a plain text-file named "pSAMSstart.cnf"). Feel free to use it if you like.

Roland Lilja

Option Explicit
Dim Tick As Integer
Dim Started As Boolean

Private Sub tmrVait_Timer()

'Try the connection to the SBDDE32 program
If Tick = 0 Then
If Not Started Then start
End If

'Uppdate time to show user that the program works
lblKlocka.Caption = "Time now - " & Now
Tick = Tick + 1
lblTemp(2).Caption = "Time left - " & Abs(Tick)
If Tick > 5 Then End

End Sub

Private Sub start()

Dim temp, sFileName As String

'Assume all is OK
Started = True
lblKlocka.Caption = "Time now - " & Now

'If it's not then run error part
On Error GoTo DDEerror
lblTemp(1).LinkMode = 0
lblTemp(1).LinkTopic = "sattbus|localserver"
lblTemp(1).LinkItem = "R1600"
lblTemp(1).LinkMode = 1
On Error GoTo 0

'It was OK! Check for the config file
If Dir("c:\sams\bin\pSAMSstart.cnf") = "" Then
MsgBox " Didn't find the file 'c:\sams\bin\pSAMSstart.cnf'"
End If

'Error handler if there is an error in the cnf file
On Error GoTo StartUppError

'Open the file to read whitch programs should start
Open "c:\sams\bin\pSAMSstart.cnf" For Input As #1

Do Until EOF(1)

'Read the filename
Line Input #1, sFileName

'Make a shellkommand to start that program
temp = Shell(sFileName, vbNormalNoFocus)


'Abort errorhandling
On Error GoTo 0

Exit Sub

'Error routine

'Error 282 means that ther is no SBDDE32 program running
If Err = 282 Then

'Set next time to try in ten seconds
Started = False
Tick = -10
lblTemp(1).Caption = "Latest atempt - " & Now
lblTemp(2).Caption = "Time left - " & Abs(Tick)


'Som other error
MsgBox "Error " & Err

End If
On Error GoTo 0
Exit Sub

'If there is a error in the cnf file then tell the opperator it

MsgBox "Error - " & Err & " " & Err.Description & " - came with" & Chr(13) & sFileName

End Sub
A simple Way to perform this and very fast
is to use DeeLink tags properties....

For instance in VB
I you can associate one textbox(text1) with a DDEitem of your DDE Server you do that

Either in Sub Main()
Or in Sub Form_Load()

text1.LinkTopic= "DDEServer|Topic"
On Error Goto NotReady
Text1.LinkMode=1 '(for automatic advise)
GoTo IsGood
DoEvents 'important!!!!
Goto TestDDE
On Error GoTo 0

How Does it works:
The Program try to Put LinkMode to Automatic advise, If DDe Server does not respond
The LinkErrorMode raises and try again until Link is established.