 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
mereketehe How do I cheat?
Reputation: 0
Joined: 30 Jun 2012 Posts: 9
|
Posted: Sat Apr 11, 2015 7:52 am Post subject: [Help] Call Exe from delphi |
|
|
Hi guys. I have a problem. How to call exe and open it automatically from button from delphi ?
Example, I already make a form in delphi, and I put the one button there. So, when I click the button, the exe will automatically open.
How to do that? Anyone have the code for me?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25817 Location: The netherlands
|
Posted: Sat Apr 11, 2015 7:58 am Post subject: |
|
|
add "windows" to the uses and call
| Code: |
ShellExecute(0, PChar('open'), PChar('c:\bla.exe'), nil, nil, 0);
| \
(assuming c:\bla.exe is the exe you wish to call)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
mereketehe How do I cheat?
Reputation: 0
Joined: 30 Jun 2012 Posts: 9
|
Posted: Sat Apr 11, 2015 8:01 am Post subject: |
|
|
| Dark Byte wrote: | add "windows" to the uses and call
| Code: |
ShellExecute(0, PChar('open'), PChar('c:\bla.exe'), nil, nil, 0);
| \
(assuming c:\bla.exe is the exe you wish to call) |
Thanks darkbyte.
Then, Is it possible that input the EXE to the delphi project. So I call the EXE from the project. Like VB.Net call the exe from the resources.
|
|
| Back to top |
|
 |
hhhuut Grandmaster Cheater
Reputation: 6
Joined: 08 Feb 2015 Posts: 607
|
Posted: Sat Apr 11, 2015 8:59 am Post subject: |
|
|
You can also use the CreateProcess API. Since it has very many parameters use the below function instead ...
| Code: |
type
TExecuteWaitEvent = procedure(const ProcessInfo: TProcessInformation; var ATerminate: Boolean) of object;
...
procedure ExecuteFile(const AFilename: String;
AParameter, ACurrentDir: String; AWait: Boolean;
AOnWaitProc: TExecuteWaitEvent=nil);
var
si: TStartupInfo;
pi: TProcessInformation;
bTerminate: Boolean;
begin
bTerminate := False;
if Length(ACurrentDir) = 0 then
ACurrentDir := ExtractFilePath(AFilename);
if AnsiLastChar(ACurrentDir) = '\' then
Delete(ACurrentDir, Length(ACurrentDir), 1);
FillChar(si, SizeOf(si), 0);
with si do begin
cb := SizeOf(si);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := SW_NORMAL;
end;
FillChar(pi, SizeOf(pi), 0);
AParameter := Format('"%s" %s', [AFilename, TrimRight(AParameter)]);
if CreateProcess(Nil, PChar(AParameter), Nil, Nil, False,
CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS, Nil, PChar(ACurrentDir), si, pi) then
try
if AWait then
while WaitForSingleObject(pi.hProcess, 50) <> Wait_Object_0 do
begin
if Assigned(AOnWaitProc) then
begin
AOnWaitProc(pi, bTerminate);
if bTerminate then
TerminateProcess(pi.hProcess, Cardinal(-1));
end;
Application.ProcessMessages;
end;
finally
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
end; |
AFileName = Path to your EXE-File (can also be a relative path)
AParamter = The parameter(s) you want to give the program
ACurrentDir = An alternate start directory. Leave empty if you want to use the actual exe directory
AWait = The calling program waits, until the exe file is closed before executing the next instruction
You can call it like this:
| Code: | | ExecuteFile('C:\bla.exe', '', '', False); |
|
|
| Back to top |
|
 |
mereketehe How do I cheat?
Reputation: 0
Joined: 30 Jun 2012 Posts: 9
|
Posted: Sat Apr 11, 2015 9:24 am Post subject: |
|
|
| hhhuut wrote: | You can also use the CreateProcess API. Since it has very many parameters use the below function instead ...
| Code: |
type
TExecuteWaitEvent = procedure(const ProcessInfo: TProcessInformation; var ATerminate: Boolean) of object;
...
procedure ExecuteFile(const AFilename: String;
AParameter, ACurrentDir: String; AWait: Boolean;
AOnWaitProc: TExecuteWaitEvent=nil);
var
si: TStartupInfo;
pi: TProcessInformation;
bTerminate: Boolean;
begin
bTerminate := False;
if Length(ACurrentDir) = 0 then
ACurrentDir := ExtractFilePath(AFilename);
if AnsiLastChar(ACurrentDir) = '\' then
Delete(ACurrentDir, Length(ACurrentDir), 1);
FillChar(si, SizeOf(si), 0);
with si do begin
cb := SizeOf(si);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := SW_NORMAL;
end;
FillChar(pi, SizeOf(pi), 0);
AParameter := Format('"%s" %s', [AFilename, TrimRight(AParameter)]);
if CreateProcess(Nil, PChar(AParameter), Nil, Nil, False,
CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS, Nil, PChar(ACurrentDir), si, pi) then
try
if AWait then
while WaitForSingleObject(pi.hProcess, 50) <> Wait_Object_0 do
begin
if Assigned(AOnWaitProc) then
begin
AOnWaitProc(pi, bTerminate);
if bTerminate then
TerminateProcess(pi.hProcess, Cardinal(-1));
end;
Application.ProcessMessages;
end;
finally
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
end;
end; |
AFileName = Path to your EXE-File (can also be a relative path)
AParamter = The parameter(s) you want to give the program
ACurrentDir = An alternate start directory. Leave empty if you want to use the actual exe directory
AWait = The calling program waits, until the exe file is closed before executing the next instruction
You can call it like this:
| Code: | | ExecuteFile('C:\bla.exe', '', '', False); |
|
can you give me an example ?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Apr 11, 2015 2:44 pm Post subject: |
|
|
| mereketehe wrote: | | can you give me an example ? |
Are you serious..? You just quoted his entire post that is an example....
_________________
- Retired. |
|
| 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 You cannot attach files in this forum You can download files in this forum
|
|