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]

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

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Fri Mar 16, 2007 9:51 pm    Post subject: [Delphi] Reply with quote

As you can see from my other threads, I'm making a Programme to run my Hacks. I know .bat is easier. But I wanted to do it the .exe way, and it looks nicer anyway.

My first prog is win32. and I'm making it without a Form, as in making it close as soon as it starts, but failed. So I added 2 buttons, 1 to run hacks and 1 to close hacks. It's successfully closed 2 of the progs but failed to close John's MzBot. The function that I'm using to close applications is

Code:
Usage:
if not KillApp('Window caption') then ShowMessage('App not closed') ;

~~~~~~~~~~~~~~~~~~~~~~~~~
function KillApp(const sCapt: PChar) : boolean;
  var AppHandle:THandle;
begin
  AppHandle:=FindWindow(Nil, sCapt) ;
  Result:=PostMessage(AppHandle, WM_QUIT, 0, 0) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~


I'm sure the Window Caption name is correct. My guess would be that it cannot close console application for some reason.




Anyway I changed the whole thing to console so that there will not be any form and used just to run my Progs.
But the ShellExecute function didn't work here.

Code:
 SetCurrentDir('D:\C Drive\Desktop\Others\Mini Engine\Mini Engine');
  ShellExecute(Handle, 'open', PChar('D:\C Drive\Desktop\Others\Mini Engine\Mini Engine\Mini Engine.exe'), nil, nil, SW_SHOW);


This is the error
Code:
[Error] Project2.dpr(10): Undeclared identifier: 'Handle'


Is there a way to fix this? Or is another function should be used since it is console application now?

_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
flawedmatrix
Grandmaster Cheater
Reputation: 0

Joined: 21 Jun 2006
Posts: 819
Location: 14598622 for yourself...

PostPosted: Fri Mar 16, 2007 10:52 pm    Post subject: Reply with quote

Where did you declare 'Handle'?
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Death4ngel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Fri Mar 16, 2007 11:46 pm    Post subject: Reply with quote

There's no problem with the Handle if it's Win32.
_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
flawedmatrix
Grandmaster Cheater
Reputation: 0

Joined: 21 Jun 2006
Posts: 819
Location: 14598622 for yourself...

PostPosted: Sat Mar 17, 2007 12:02 am    Post subject: Reply with quote

You mean console app? Or .NET?
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Death4ngel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Sat Mar 17, 2007 12:30 am    Post subject: Reply with quote

Now it's console application. The ShellExecute doesn't work.
_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Sat Mar 17, 2007 12:46 am    Post subject: Reply with quote

Code:
function TForm1.KillTask (ExeFileName : string) : integer;
const
    PROCESS_TERMINATE = $0001;
var
    ContinueLoop : boolean;
    FsnapshotHandle : THandle;
    FProcessEntry32 : TProcessEntry32;
begin
result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof (FProcessEntry32);
ContinueLoop := Process32First (FSnapshotHandle, FProcessEntry32);


    while integer (ContinueLoop) <> 0 do
    begin
        if ((UpperCase (ExtractFileName (FProcessEntry32.szExeFile)) = UpperCase (ExeFileName)) or (UpperCase          (FProcessEntry32.szExeFile) = UpperCase (ExeFileName))) then
            Result := Integer (TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0));
            ContinueLoop := Process32Next (FSnapshotHandle, FProcessEntry32);
    end;


    CloseHandle (FSnapshotHandle);
end;






And then, after you've implemented it, you can use it like this.......


Say for instance that I've got Notepad running on my computer. Therefore, in order to kill its accompanying process' handle, I'd make a call to this function from within the event handler that's supposed to trigger this whole operation.


For example, if a click on Button1 is supposed to trigger this operation, I'll create an onClick() event handler and my code will be something like :


Code:
procedure TForm1.Button1Click..........
begin
    KillTask ('Notepad.exe');
end;

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Sat Mar 17, 2007 12:47 am    Post subject: Reply with quote

You didn't declare Handle. Try passing in null there instead.
_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
flawedmatrix
Grandmaster Cheater
Reputation: 0

Joined: 21 Jun 2006
Posts: 819
Location: 14598622 for yourself...

PostPosted: Sat Mar 17, 2007 1:06 am    Post subject: Reply with quote

Hmm, console apps don't have the usual uses list, cause they only have SysUtils in the list, so put shellapi and forms in the list.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Death4ngel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Sat Mar 17, 2007 1:09 am    Post subject: Reply with quote

DeltaFlyer wrote:
You didn't declare Handle. Try passing in null there instead.


I tried putting nill, gave me some hwnd and pointer error.

_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
flawedmatrix
Grandmaster Cheater
Reputation: 0

Joined: 21 Jun 2006
Posts: 819
Location: 14598622 for yourself...

PostPosted: Sat Mar 17, 2007 1:11 am    Post subject: Reply with quote

It needs a handle to work. Neutral
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Death4ngel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Sat Mar 17, 2007 4:04 am    Post subject: Reply with quote

WinExec Works. haha. thanks.

EDIT: I'm still having problems with closing MzBot Lite. Even this code doesn't work. Is it because it's a console application?

Code:
  PostMessage(FindWindow(Nil, 'D:\C Drive\Desktop\Others\MzBot_Lite-2.0.0-Beta\MzBot_Lite-2.0.0-Beta.exe'), WM_QUIT, 0, 0);

_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
flawedmatrix
Grandmaster Cheater
Reputation: 0

Joined: 21 Jun 2006
Posts: 819
Location: 14598622 for yourself...

PostPosted: Sat Mar 17, 2007 12:22 pm    Post subject: Reply with quote

Use the_undead's kill task procedure to kill MzBot. What you used was to send a message to MzBot to close itself.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
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