|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
tesla
Joined: 09 Dec 2007 Posts: 1
|
Posted: Tue Dec 11, 2007 7:50 pm Post subject: Close a process??? |
|
|
Hi everybody.I want to know how to close a program.I know how to open it,with the command "start_process@()" but i do not know how to exit .Please if you have the answear pls post.Thanks |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Wed Dec 12, 2007 8:36 am Post subject: |
|
|
There is no function to close a process started by start_process@.
It is assumed that the process will have its own closing mechanism.
I guess we could provide new functions for this purpose but they do not exist at the moment.
Such functions would be based on the API CreateProcess and would use the process handle that it creates, so in principle you could provide your own functions on this basis.
Having said this, it is not natural or usual to terminate a process via its process handle in this way. It would essentially represent an abort mechanism. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Dec 24, 2007 7:15 pm Post subject: |
|
|
Isn't this a case for SEND_TEST_MESSAGE@ to tell the application to commit Hari Kiri, and the the self-destructing application to REPLY_TO_TEXT_MESSAGE@ confirming that it is closing? Presumably the callback routine for %rm needs to have an ABORT@
Easy enough if the application one wants to close is one's own, and it was written in FTN95! Not easy if it is (say) MS Excel and one doesn't know the class name of its main window ! |
|
Back to top |
|
|
JohnHorspool
Joined: 26 Sep 2005 Posts: 270 Location: Gloucestershire UK
|
Posted: Wed Dec 26, 2007 3:51 pm Post subject: |
|
|
About ten years ago I downloaded a zip file containing unix commands for DOS, among which were "ps" and "kill" to list current processes and kill a process respectively. Using these it would be a trivial task to write a FTN95 application that launches the "ps" command with CISSUE, the output of which will provide a process ID number that can be closed with "kill", also launched by CISSUE.
However the web site that provided this zip file no longer exists, and a google search didn't yield anything similar (only complete unix emulations within windows and vice versa!). As far as I know there is no DOS equivalent for these unix commands. But if anyone really wants this zip file, they can contact me via a private message. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Dec 28, 2007 11:25 pm Post subject: |
|
|
Yes, the SEND_TEXT_MESSAGE@ route is the correct one. Let us suppose that you have a program FRED that launches another program GINGER using CALL START_PPROCESS@. At some later stage, you want to close GINGER from inside FRED. I’m assuming that you want to start GINGER with a START_PPROCESS@, because a START_PROCESS@ doesn’t return control to FRED until GINGER closes (according to the FN95 help).
Somewhere in FRED, you have, perhaps as a callback routine, a way of starting GINGER:
INTEGER FUNCTION Start_Ginger_FN()
INTEGER START_PPROCESS@, SEND_TEXT_MESSAGE@
CHARACTER*(25) REPLY
INCLUDE <WINDOWS.INS>
IA = SEND_TEXT_MESSAGE@('Rogers','RUNNING',REPLY)
IF (REPLY .NE. 'YES') THEN
IA = START_PPROCESS@('Ginger.EXE',' ')
ENDIF
Start_Ginger_FN = 1
END
Provided that the main window in GINGER.EXE had the class name ‘Rogers’, and the callback within GINGER.EXE replied to a ‘RUNNING’ message with a ‘YES’, then this prevents a second instance of GINGER.EXE from running.
You also have somewhere a route to code that terminates execution of GINGER, i.e.
IA = SEND_TEXT_MESSAGE@('Rogers','CLOSE',REPLY)
In GINGER, as part of the Clearwin code to open its main window, you need:
IA=WINIO@('%nc[Rogers]%rm&',MESSAGE_FN)
%nc establishes that the class name of this window is ‘Rogers’, so that it receives a message addressed to it. %rm is followed by the callback function to handle text messages, in this case called MESSAGE_FN(). MESSAGE_FN needs to be declared EXTERNAL in the usual way.
INTEGER FUNCTION MESSAGE_FN()
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
I have included the extra code to inhibit the second instance of GINGER being started, although presumably, if there is more than one instance of GINGER then they all close on receipt of the message. (The callback function return value of 0 will close the main window in GINGER in the normal run of things).
That is as far as I have tested, but I am prepared to bet that if you have a text message handler in all windows launched by GINGER they could all be closed from FRED with one message, or a series of messages.
Apologies for misspelling SEND_TEXT_MESSAGE@ as SEND_TEST_MESSAGE@ in my earlier post. Also, you don’t need anything as draconian as ABORT@ - simply a callback function return value of 0 will do to close a window.
Since SEND_TEXT_MESSAGE@ returns 0 if class 'Rogers' isn't found, then there is an alternative way of detecting whether GINGER is running - by testing IA.
Eddie |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Sun Dec 30, 2007 1:19 pm Post subject: |
|
|
It seems that multiple windows in the same program can't have the same class name under %nc, (i.e. "class" is "class of one") but that they can all have the same callback function to handle %rm.
I suppose that any process started by START_PPROCESS@ that one wants to send a message to needs to be an FTN95/Clearwin application, as there is no other way to give it a class name (no SET_CLASS_NAME@ routine for instance), and even if there was, there is no other way to set up a message handler other than the callback for %rm.
Eddie |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|