GSM Shop GSM Shop
GSM-Forum  

Welcome to the GSM-Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features.
Only registered members may post questions, contact other members or search our database of over 8 million posts.

Registration is fast, simple and absolutely free so please - Click to REGISTER!

If you have any problems with the registration process or your account login, please contact contact us .

Go Back   GSM-Forum > Other Gsm/Mobile Related Forums > GSM Programming & Reverse Engineering


GSM Programming & Reverse Engineering Here you can post all Kind of GSM Programming and Reverse Engineering tools and Secrets.

Reply
 
LinkBack Thread Tools Display Modes
Old 01-31-2017, 00:28   #1 (permalink)
Insane Poster
 
Join Date: Jan 2017
Posts: 95
Member: 2674769
Status: Offline
Thanks Meter: 17
send adb commands and recive output delphi


send adb commands and recive output delphi

whats the best method
  Reply With Quote
Old 01-31-2017, 05:50   #2 (permalink)
No Life Poster
 
darmiles's Avatar
 
Join Date: Sep 2005
Location: Resign
Posts: 525
Member: 177036
Status: Offline
Thanks Meter: 934
Donate money to this user
functio n GetDosOutput(CommandLine: string; Work: string = 'C:\'): string;
var
SA: TSecurityAttributes;
SI: TStartupInfo;
PI: TProcessInformation;
StdOutPipeRead, StdOutPipeWrite: THandle;
WasOK: Boolean;
Buffer: array[0..255] of AnsiChar;
BytesRead: Cardinal;
WorkDir: string;
Handle: Boolean;
begin
Result := '';
with SA do begin
nLength := SizeOf(SA);
bInheritHandle := True;
lpSecurityDescriptor := nil;
end;
CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
try
with SI do
begina
FillChar(SI, SizeOf(SI), 0);
cb := SizeOf(SI);
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
hStdOutput := StdOutPipeWrite;
hStdError := StdOutPipeWrite;
end;
WorkDir := Work;
Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
nil, nil, True, 0, nil,
PChar(WorkDir), SI, PI);
CloseHandle(StdOutPipeWrite);
if Handle then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
Result := Result + Buffer;
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(PI.hProcess, INFINITE);
finally
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
end;
finally
CloseHandle(StdOutPipeRead);
end;
end;

CALL
Quote:
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text:='adb devices';
Memo1.Text := GetDosOutput(edit1.text);
end;
  Reply With Quote
The Following User Says Thank You to darmiles For This Useful Post:
Old 02-02-2017, 03:05   #3 (permalink)
Insane Poster
 
Join Date: Jan 2017
Posts: 95
Member: 2674769
Status: Offline
Thanks Meter: 17
I used this before but when press botton1

My app freeze why

I used it delphi7 and 2010

In
windows8
  Reply With Quote
Old 02-03-2017, 23:18   #4 (permalink)
Insane Poster
 
Join Date: Jan 2017
Posts: 95
Member: 2674769
Status: Offline
Thanks Meter: 17
sorry i tried this and it work perfect
  Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


 



All times are GMT +1. The time now is 05:24.



Powered by Searchlight © 2024 Axivo Inc.
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
- GSM Hosting Ltd. - 1999-2023 -
Page generated in 0.11188 seconds with 8 queries

SEO by vBSEO