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
public
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.
![Smilie](http://www.clubdelphi.com/foros/images/smilies/smile.gif)
![Stick Out Tongue](http://www.clubdelphi.com/foros/images/smilies/tongue.gif)
![Big Grin](http://www.clubdelphi.com/foros/images/smilies/biggrin.gif)