Assume your 2 processes were both written in FTN95.
In the main window creation for P2, set it's process name and a callback function thus:
IA=WINIO@('%nc[P2_process_name]%rm&',MESSAGE_FN)
The code to launch P2 needs to look something like:
INTEGER FUNCTION LaunchP2_FN()
C -------------------------------
C
C Launch P2.exe
C
C -----------------------------------------------------------------
INTEGER START_PPROCESS@, SEND_TEXT_MESSAGE@
CHARACTER*(25) REPLY
INCLUDE <WINDOWS.INS>
C ------------------------------------------------------------------
IA = SEND_TEXT_MESSAGE@('P2_process_name','RUNNING',REPLY)
IF (REPLY .NE. 'YES') THEN
IA = START_PPROCESS@('P2.EXE',' ')
IF (IA .NE. 0) write(*,*) 'Did not start P2'
ENDIF
LaunchP2_FN = 1
END
The callback in P2 looks like this:
INTEGER FUNCTION MESSAGE_FN()
C -----------------------------
C
CHARACTER*(255) MESSAGE
INCLUDE <WINDOWS.INS>
MESSAGE = CLEARWIN_STRING@('MESSAGE_TEXT')
IF (MESSAGE .EQ. 'CLOSE') THEN
MESSAGE_FN = 0
RETURN
ELSE IF (MESSAGE .EQ. 'RUNNING') THEN
CALL REPLY_TO_TEXT_MESSAGE@('YES')
ENDIF
MESSAGE_FN = 1
RETURN
END
Essentially, P1 sends the message 'RUNNING' to P2. If there is no reply, then P2 can be started. If there is an answer, it will be 'YES', in which case do not start P2 at all, because it is already running. P1 can also send the message 'CLOSE' (using SEND_TEXT_MESSAGE@), in which case P2 should shut itself down. In that case, the reply specified in the SEND_TEXT_MESSAGE@ call might just as well be ignored.
Be sure to read all about Windows messaging in FTN95.CHM.
Eddie