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] DLL which changes the title of process

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

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sun Dec 21, 2008 11:08 am    Post subject: [Delphi] DLL which changes the title of process Reply with quote

Well I am trying to do a simple dll which:

•When i inject the dll in the process, the dll changes the application title.

I am doing the following:

Quote:
library Project2;

uses
Windows,
SysUtils,
Classes;

{$R *.res}

var
myhandle:thandle;
begin
myhandle:=0;
myhandle:=GetCurrentProcess;
if myhandle<>0 then
begin

Messagebox(0,'Click OK to change the title of the application','',0);
SetWindowText(myhandle,'MYNEWTITLEISHERE');
end;
end.


But it does not work => the title just does not change at all ... but I see the message box, since the value is different than 0 and seems that "i have the handle".

_________________



Last edited by h4c0r-BG on Sun Dec 21, 2008 11:10 am; edited 1 time in total
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Sun Dec 21, 2008 11:10 am    Post subject: Reply with quote

Code:
BOOL SetWindowText(     
    HWND hWnd,
    LPCTSTR lpString
);


SetWindowText takes a handle to the window, aka hWnd.

A handle to the window is different than a handle to your process, which is obtained from GetCurrentProcess.

Use the FindWindow API to get a handle to the window.

Code:
HWND FindWindow(     
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName
);



Example:
Code:
SetWindowText(FindWindow(0,'MyWindowName'),'NewWindowName!');



Or in yours...

Quote:
library Project2;

uses
Windows,
SysUtils,
Classes;

{$R *.res}

var
myhandle:thandle;
begin
myhandle:=0;
myhandle:=FindWindow(0,'WindowName');
if myhandle<>0 then
begin

Messagebox(0,'Click OK to change the title of the application','',0);
SetWindowText(myhandle,'MYNEWTITLEISHERE');
end;
end.


Last edited by smartz993 on Sun Dec 21, 2008 11:14 am; edited 1 time in total
Back to top
View user's profile Send private message
h4c0r-BG
Master Cheater
Reputation: 0

Joined: 29 Nov 2006
Posts: 449
Location: The yogurt country

PostPosted: Sun Dec 21, 2008 11:13 am    Post subject: Reply with quote

Solved. Thank you very much. Smile
_________________

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