Ver Mensaje Individual
  #14  
Antiguo 02-03-2008
JoseFco JoseFco is offline
Baneado
 
Registrado: dic 2007
Posts: 1.861
Reputación: 0
JoseFco cantidad desconocida en este momento
Código Delphi [-]
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Label1: TLabel;
    OpenDialog1: TOpenDialog;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
 function HextoInt(HexStr: String):integer;
const Hex : array['A'..'F'] of integer = (10,11,12,13,14,15);
var
    i   : integer;
begin
  Result:=0;
  for i := 1 to Length(HexStr) do
    if HexStr[i] < 'A' then Result := Result * 16 + Ord(HexStr[i]) - 48
                       else Result := Result * 16 + Hex[HexStr[i]];
end;
Function IntelHexFinalFileSize(const FileName: String): Integer;
var
 S: TStrings;
 n, FinalSize: Integer;
begin
 FinalSize:=0;
 S:=TStringList.Create;
 S.LoadFromFile(FileName);
 For n:=0 to S.Count-1 do Inc(FinalSize, HexToInt(Copy(S[n],2,2)));
 S.Free;
 Result:=FinalSize;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
  begin
  Label1.Caption:=OpenDialog1.FileName;
  Memo1.Lines.LoadFromFile(Label1.Caption);
  Label2.Caption:=IntToStr(IntelHexFinalFileSize(Label1.Caption));
end;
end;
end.

Gracias al amigo ixMike asunto resuelto.
Responder Con Cita