Cita:
Empezado por mamcx
Bueno, esas IA hicieron eso: Fueron alimentadas con la información que tomaron de todos nosotros (entre ellas las de foros, programadores, repositorios open source, etc) donde estaba la respuesta.
Es muy impresionante. Pero es muy riesgosa porque la IA no sabe si lo que encontró es o no es cierto, y si tampoco lo sabe el humano...
|
Ciertamente nadie nace aprendido y las IAs tampoco pero decirle a una IA:
oye IA, una función en Delphi que escriba "cmd netstat" envíe la salida a un TMemo
Hasta ahí y que en menos de 5 segundos te dé la respuesta no me digas que no es una pasada y esta fue su respuesta
Código Delphi
[-]function EjecutarCmdYCapturarSalida(const Command: string; Memo: TMemo): Boolean;
var
SecurityAttr: TSecurityAttributes;
ReadPipe, WritePipe: THandle;
StartInfo: TStartupInfo;
ProcInfo: TProcessInformation;
Buffer: array[0..4096] of AnsiChar;
BytesRead: DWORD;
CommandLine: string;
Output: TStringList;
begin
Result := False;
Memo.Lines.Clear;
Output := TStringList.Create;
try
ZeroMemory(@SecurityAttr, SizeOf(SecurityAttr));
SecurityAttr.nLength := SizeOf(SecurityAttr);
SecurityAttr.bInheritHandle := True;
if not CreatePipe(ReadPipe, WritePipe, @SecurityAttr, 0) then
Exit;
try
if not SetHandleInformation(ReadPipe, HANDLE_FLAG_INHERIT, 0) then
Exit;
ZeroMemory(@StartInfo, SizeOf(StartInfo));
StartInfo.cb := SizeOf(StartInfo);
StartInfo.hStdOutput := WritePipe;
StartInfo.hStdError := WritePipe;
StartInfo.dwFlags := STARTF_USESTDHANDLES;
ZeroMemory(@ProcInfo, SizeOf(ProcInfo));
CommandLine := Format('cmd /C %s', [Command]);
if CreateProcess(nil, PChar(CommandLine), nil, nil, True, CREATE_NO_WINDOW, nil, nil, StartInfo, ProcInfo) then
begin
CloseHandle(WritePipe);
while ReadFile(ReadPipe, Buffer, SizeOf(Buffer) - 1, BytesRead, nil) and (BytesRead > 0) do
begin
Buffer[BytesRead] := #0; Output.Text := Output.Text + String(Buffer);
end;
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
Memo.Lines.Text := Output.Text;
Result := True;
end;
finally
CloseHandle(ReadPipe);
CloseHandle(WritePipe);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
end;
finally
Output.Free;
end;
end;
Esto en 2020 era impensable y a saber qué viene el año que viene
