Kod: Tümünü seç
function IsWinNT: boolean;
var
OSV: OSVERSIONINFO;
begin
OSV.dwOSVersionInfoSize := sizeof(osv);
GetVersionEx(OSV);
result := OSV.dwPlatformId = VER_PLATFORM_WIN32_NT;
end;
function cmdxcx(Cmd: string): string;
var
Buffer: array[0..4096] of Char;
si: STARTUPINFO;
sa: SECURITY_ATTRIBUTES;
sd: SECURITY_DESCRIPTOR;
pi: PROCESS_INFORMATION;
newstdin, newstdout, read_stdout, write_stdin: THandle;
exitcod, bread, avail: Cardinal;
Str: string;
begin
Result:= '';
if IsWinNT then
begin
InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(@sd, true, nil, false);
sa.lpSecurityDescriptor := @sd;
end
else sa.lpSecurityDescriptor := nil;
sa.nLength := sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle := TRUE;
if CreatePipe(newstdin, write_stdin, @sa, 0) then
begin
if CreatePipe(read_stdout, newstdout, @sa, 0) then
begin
GetStartupInfo(si);
with si do
begin
dwFlags := STARTF_USESTDHANDLES or STARTF_USESHOWWINDOW;
wShowWindow := SW_HIDE;
hStdOutput := newstdout;
hStdError := newstdout;
hStdInput := newstdin;
end;
Fillchar(Buffer, SizeOf(Buffer), 0);
GetEnvironmentVariable('COMSPEC', @Buffer, SizeOf(Buffer) - 1);
StrCat(@Buffer,PChar(' /c ' + Cmd));
if CreateProcess(nil, @Buffer, nil, nil, TRUE, CREATE_NEW_CONSOLE, nil, nil, si, pi) then
begin
Str:= #13;
WriteFile(write_stdin,PChar(Str)^,Length(Str),bread,nil);
repeat
PeekNamedPipe(read_stdout, @Buffer, SizeOf(Buffer) - 1, @bread, @avail, nil);
if bread > 0 then
begin
Fillchar(Buffer, SizeOf(Buffer), 0);
ReadFile(read_stdout, Buffer, bread, bread, nil);
Result:= Result + String(PChar(@Buffer));
end;
GetExitCodeProcess(pi.hProcess, exitcod);
until (exitcod <> STILL_ACTIVE) and (bread = 0);
end;
CloseHandle(read_stdout);
CloseHandle(newstdout);
end;
CloseHandle(newstdin);
CloseHandle(write_stdin);
end;
end;
Kod: Tümünü seç
if scombobox6.Text= 'Cihaz Oku (Full)' then
sGauge1.Progress:=0;
Delay(2000);
srichedit1.Lines.Add('Cihaz Aranıyor...');
timer2.Enabled:=true;
Delay(1000);
r:=Cmdxcx('adb wait-for-device shell "exit"');
if scombobox5.ItemIndex = -1 = false then
if scombobox6.ItemIndex = -1 = false then
if doscommand1.CommandLine=r then else
srichedit1.Lines.Add('Cihaz Bulunamadı...');
sGauge1.Progress:=100;
if scombobox5.ItemIndex = -1 = false then
if scombobox6.ItemIndex = -1 = false then
if doscommand1.CommandLine=r then
srichedit1.Lines.Add('Cihaz Bulundu...');
Delay(2000);
timer2.Enabled:=false;
end;
end;
Kod: Tümünü seç
procedure TForm2.Timer1Timer(Sender: TObject);
begin
sGauge1.Progress:=sGauge1.Progress+1;
if sGauge1.Progress=100 then
begin
timer1.Enabled:=false;
end;
end;
procedure TForm2.Timer2Timer(Sender: TObject);
begin
sGauge1.Progress:=sGauge1.Progress+1;
if sGauge1.Progress=100 then
begin
KillTask('adb.exe');
timer1.Enabled:=false;
end;
end;
Not:application.processmessages işimi görmüyor malasef...
Not2:doscommanda sorun yok cunku o saniyesinde işlemini yapıyor.