Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Delphi stop and application from starting or running

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sat Apr 12, 2008 1:59 am    Post subject: Delphi stop and application from starting or running Reply with quote

hey, i was wondering if anyone could help me with a little something im working on, basically im trying to stop a process or application from running, anyone got any ideas?
_________________
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat Apr 12, 2008 2:35 am    Post subject: Reply with quote

http://www.latiumsoftware.com/en/delphi/00034.php
Quote:
To close another application you can use the PostMessage API declared in the Windows unit to send a WM_CLOSE message to its main form. This function requires the handle of the window to which you want to post the message. You can get this handle for example using the FindWindow API, also declared in the Windows unit.

Here is a source code example:

uses Windows, Messages;

procedure TForm1.Button1Click(Sender: TObject);
var
h: HWND;
begin
h := FindWindow(nil, 'Main Form Caption');
if h <> 0 then PostMessage(h, WM_CLOSE, 0, 0);
end;

Instead of 'Main Form Caption' you should write the title (caption) of the main form of the application you want to close. Be sure this name is unique or you might end up closing another application (for example it wouldn't be good a name like 'Form1').
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Sat Apr 12, 2008 4:36 am    Post subject: Reply with quote

thanks moller, works well
_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Apr 12, 2008 11:28 am    Post subject: Reply with quote

If you're going to use FindWindow, use the class instead of the actual window name.
Back to top
View user's profile Send private message
NothingToShow
Grandmaster Cheater Supreme
Reputation: 0

Joined: 11 Jul 2007
Posts: 1579

PostPosted: Sat Apr 12, 2008 1:07 pm    Post subject: Reply with quote

slovach wrote:
If you're going to use FindWindow, use the class instead of the actual window name.

I've got a question about the class name thing.
How do you know what the classname is?
Back to top
View user's profile Send private message
killersamurai
Expert Cheater
Reputation: 0

Joined: 10 Sep 2007
Posts: 197
Location: Colorado

PostPosted: Sat Apr 12, 2008 1:24 pm    Post subject: Reply with quote

GetClassName()
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Apr 12, 2008 1:59 pm    Post subject: Reply with quote

Moller wrote:
slovach wrote:
If you're going to use FindWindow, use the class instead of the actual window name.

I've got a question about the class name thing.
How do you know what the classname is?


Spy++
Back to top
View user's profile Send private message
rapion124
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Mar 2007
Posts: 1095

PostPosted: Sat Apr 12, 2008 7:43 pm    Post subject: Reply with quote

Lol. It's ironic that you need a window handle to obtain the class, when obtaining the window handle requires the class or caption.
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Sun Apr 13, 2008 1:36 am    Post subject: Reply with quote

rapion124 wrote:
Lol. It's ironic that you need a window handle to obtain the class, when obtaining the window handle requires the class or caption.

Or, you could loop through all windows and get the class name, window name AND handle using GetWindow, GetClassNameA/W and GetWindowTextA/W APIs. Razz
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites