Hola, aqui pongo el codigo que yo hago para todo lo que necesito hacer, primero averiguo el numero de serie del hd despues le quito el signo (-) y despues lo convierto a decimal.
1.º El numero de serie es este 90A0-03FE
2.º Al quitarle el signo - se queda en 90A003FE
3.º Y al convertirlo me da -1868561410
¿que hago mal? aqui teneis el codigo.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
SpeedButton1: TSpeedButton;
Edit1: TEdit;
procedure FormActivate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
Function QuitaMenos(S:String):String;
begin
while Pos('-', S) > 0 do
Delete(s,Pos('-', S),1);
Result:=S;
end;
function HexToInt(const Value: String): Integer;
begin
Result := StrToInt('$' + Value);
end;
function GetVolumeID(DriveChar: Char): String;
var
MaxFileNameLength, VolFlags, SerNum: DWord;
begin
if GetVolumeInformation(PChar(DriveChar + ':\'), nil, 0,
@SerNum, MaxFileNameLength, VolFlags, nil, 0)
then
begin
Result := IntToHex(SerNum,8);
Insert('', Result, 5);
end
else
Result := '';
end;
{$R *.dfm}
procedure TForm1.FormActivate(Sender: TObject);
begin
Label1.Caption:=GetVolumeId('c');
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
Label2.Caption:=IntToStr( HexToInt(label1.Caption) );
end;
end.
Salu2.CRIS.
|