Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / How To End Another Program(.exe)?

Author
Message
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 12th Mar 2004 18:38
Hi guys, i'm just wondering if it would be possible to end a currently running program from within a different program,
eg.
Main.exe is run
Main.exe tells Second.exe to load(via execute file)
When Main.exe is closed, Second.exe is still running
The user then has to close Second.exe, which is an inconvenience.

Is there a command in dbp, or a .dll i can use which will close that program(Second.exe)? Both programs are made in dbp.

Thanks for any help you can give

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com
Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 12th Mar 2004 19:09
You could probably do it by playing around with TerminateProcess (Win32 API) but that might be a bit fiddly. If timing is not absolutely critical, just create a specific file which second.exe looks for then closes if it finds it.

eg:

do
...code...
if (file exist("die"))
delete file "die"
end
endif
loop

BlueGUI:Windows UI Plugin - All the power of the windows interface in your DBPro games. - Plus URL download, win dialogs.
Over 140 new commands
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 12th Mar 2004 19:09
there are a few ways in general to do this but I am not sure if any are implemented in dbp.


"What the... Moooooooo!"
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 12th Mar 2004 19:24
hmmm, i actually thought about the creating a file technique right after posting, that would be ok i guess. How fiddly would terminate process be exactly? if its just a case of loading and calling a .dll then i think i could manage that...

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com
Mussi
22
Years of Service
User Offline
Joined: 27th Jan 2003
Location: Netherlands
Posted: 12th Mar 2004 20:00
you could use the clipboard for this, like second.exe continuesly checks the clipboard if it contains something like "main.exe is closed" and make your main.exe so that it writes "main.exe is closed" to the clipboard once you end the program.



Specs: AMD Athlon 1800, 256 DDRRam 266mhz, 80GB HD 7200rmp U133, Geforce 4 Ti4400 128mb
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 12th Mar 2004 20:37
If you can get the window handle, you could send a quit message to it.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
wh1sp3r
21
Years of Service
User Offline
Joined: 28th Sep 2003
Location: Czech republic
Posted: 12th Mar 2004 21:06
hmmm ... you can create file ... firts program on end write to file something, and second will be read and close, if in file will be ... example "exit"

☺☺ PIII 950 Mhz, 320 MB RAM, GeForce4MX440 64MB, SB LIVE!, monitor 19" ☺☺
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 12th Mar 2004 21:09
i have a function that does this via the win process id or the name of the process. It attempts the CloseMainWindow method, then checks if it shut down, if not it Kills the process, but unfortunately this is vb.net so there goes that idea.


"What the... Moooooooo!"
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 12th Mar 2004 21:20
is the window handle the same as the window caption? eg. the name at the top of the window? if so thats pretty easy to get, if not i'll probably use mussi's clipboard method, that sounds pretty good

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com
Terabyte
22
Years of Service
User Offline
Joined: 28th Dec 2002
Location: UK
Posted: 12th Mar 2004 21:22
i will post delphi7 code here if you want it (please reply if you do) which you can pop in a dll (dont ask me how) and it will terminate the process (provided you give it the window caption(which must be unique))

The following threads and their accompanying sound tracks are protected by copyright and any broadcast public diffusion, copying and edditing are etc... etc.. you may not complain about my Typo's
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 12th Mar 2004 21:23
for dbp the clipboard thing should do the trick


"What the... Moooooooo!"
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 12th Mar 2004 21:24
thanks for the offer terrabyte, but i have no knowledge of delphi at all so it wouldn't be too good for me i'll give the clipboard method a try...

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com
Rob K
Retired Moderator
22
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 12th Mar 2004 21:43
DBPro code:



Replace "Get Class Name" AND "TForm1" with your program's window title.

BlueGUI:Windows UI Plugin - All the power of the windows interface in your DBPro games. - Plus URL download, win dialogs.
Over 140 new commands
ReD_eYe
22
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 12th Mar 2004 22:27
wicked! it works great, thanks rob!

In the beginning, the universe was created...
This made alot of people very angry and it has been widely regarded as a bad idea...
Visit http://redeye.dbspot.com

Login to post a reply

Server time is: 2025-06-18 06:01:41
Your offset time is: 2025-06-18 06:01:41