Cita:
Empezado por ecfisa
Hola.
Si no te entiendo mal habías logrado cargar la lista de HWIDs al memo, por lo que prácticamente ya lo tenías solucionado. Solo te faltó revisar si el el HWID existía en la lista obtenida.
Para ejemplificar, uso la dirección de tu mensaje número #4 y algunas palabras de su contenido:
Código Delphi [-]
...
uses IdHTTP;
function GetHWID: string;
begin
Result := 'estoy bastante apurado con esto !!!';
end;
function TForm1.TryConnect(const aURL: string; TS: TStrings): Boolean;
begin
Result := True;
with TidHTTP.Create(nil) do
try
try
HandleRedirects := True;
TS.Text := Get(aURL);
Caption := ResponseText
except
on E: Exception do
begin
MessageBox(Handle, PChar(E.Message),'Error',MB_ICONERROR+MB_OK);
Result := False
end
end;
finally
Free
end;
end;
procedure TForm1.btnVerificarClick(Sender: TObject);
const
URL_MSG = 'el url del post4 no me permite poner links';
var
TS: TStrings;
begin
TS := TStringList.Create;
try
if TryConnect(URL_MSG, TS) then
if Pos(GetHWID, TS.Text) = 0 then
raise Exception.Create('Error: HWID no identificado');
ShowMessage('Form2 continua -> "Abre un Form"');
...
finally
TS.Free;
end;
end;
Si cambias algo del texto que devuelve la función GetHWID no será encontrado y lanzará la excepción.
Saludos
|
Hola muchas gracias por tomarte tu tiempo y poder explicar y/o entender que era lo que trataba de explicar y lo cual no encontraba soluciones de manera no , satisfactoria ayer era la entrega de Proyectos y no pude terminar el mío me tuve que integrar con un grupo que hicieron otro proyecto ..
Bueno en este caso revisando un poco el código que posteastes al momento de implementarlo y situar nuevamente en lo que es el code , me lanza algunos errores eh intentado cambiar de lugar algunas cosas y modificarlas pero aún así no logro terminar de declarar algunas funciones para que pueda compilar sin errores saludos y gracias por tu cooperación !
Tras estar un rato mirandolo recibo un par de errores que me tienen loco si estan declaradas las strings porque me da estos errores ?
Cita:
[Error] Unit1.pas(40): Undeclared identifier: 'TryConnect'
[Error] Unit1.pas(40): '=' expected but ';' found
[Error] Unit1.pas(40): '=' expected but ')' found
[Error] Unit1.pas(41): Missing operator or semicolon
[Error] Unit1.pas(42): Undeclared identifier: 'Result'
[Error] Unit1.pas(48): Undeclared identifier: 'Caption'
[Error] Unit1.pas(52): Undeclared identifier: 'Handle'
[Error] Unit1.pas(108): Undeclared identifier: 'TryConnect'
[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
|
Código Delphi
[-]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, CWMIBase, CProcessorInfo, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;
type
TGetValueFunction = Function: String of object;
TForm1 = class(TForm)
ProcessorInfo1: TProcessorInfo;
edtProcessorID: TEdit;
Label1: TLabel;
Memo1: TMemo;
IdHTTP1: TIdHTTP;
Button1: TButton;
btnVerificar: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure btnVerificarClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
function GetHWID: string;
begin
Result := 'Probando a ver que pasará ..';
end;
function TForm1.TryConnect(const aURL: string; TS: TStrings): Boolean;
begin
Result := True;
with TidHTTP.Create(nil) do
try
try
HandleRedirects := True;
TS.Text := Get(aURL);
Caption := ResponseText
except
on E: Exception do
begin
MessageBox(Handle, PChar(E.Message),'Error',MB_ICONERROR+MB_OK);
Result := False
end
end;
finally
Free
end;
end;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
dd:TProcessorInfo;
ddProps:TProcessorProperties;
InKB, InMB, InGBouble;
str:string;
begin
dd := ProcessorInfo1;
ddProps := dd.ProcessorProperties;
edtProcessorID.Text := ddProps.ProcessorId;
end;
procedure TForm1.Button1Click(Sender: TObject);
var HTTPCLIENT1: TIdHTTP;
begin
try
try
HTTPCLIENT1 := TIdHTTP.Create(nil);
Memo1.Clear;
with HTTPCLIENT1 do
begin
HandleRedirects := True;
Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31';
Memo1.Text := Get('http://hdwid.foroargentina.net/h1-hdwid');
end;
except
On e: Exception do
begin
Memo1.Lines.Add('Exception: '+e.Message);
end;
end;
finally
HTTPCLIENT1.Free;
end;
end;
procedure TForm1.btnVerificarClick(Sender: TObject);
const
URL_MSG = 'http://hdwid.foroargentina.net/h1-hdwid';
var
TS: TStrings;
begin
TS := TStringList.Create;
try
if TryConnect(URL_MSG, TS) then
if Pos(GetHWID, TS.Text) = 0 then
raise Exception.Create('Error: HWID no identificado');
ShowMessage('Form2 continua -> "Abre un Form"');
finally
TS.Free;
end;
end;
end.