Numero do HD

Delphi

22/12/2003

Boa tarde GALERA,
gostaria de saber como faço para pegar o nº de serie do HD.

Agradeço

wilker


Wfiorio

Wfiorio

Curtidas 0

Respostas

Luis.soft

Luis.soft

22/12/2003

Olá Amigo ! Como vai ?!

Você pode usar esta função:

Function SerialNum(FDrive:String) :String;
Var
Serial:DWord;
DirLen,Flags: DWord;
DLabel : Array[0..11] of Char;
begin
Try GetVolumeInformation(PChar(FDrive+´:\´),dLabel,12,@Serial,DirLen,Flags,nil,0);
Result := IntToHex(Serial,8);
Except Result :=´´;
end;
end;

Coloque ela na seção Implementation da sua Unit.
Em seguida, por exemplo no clique do botão ou e qualquer evento que desejar, chame-a.
Por exemplo:

Edit.Text := SerialNum(´C´);

Ok ?!

Abraços,

Luis Soares


GOSTEI 0
Luis.soft

Luis.soft

22/12/2003

A função correta é:

Function SerialNum(FDrive:String) :String;
Var
Serial:DWord;
DirLen,Flags: DWord;
DLabel : Array[0..11] of Char;
begin
Try GetVolumeInformation(PChar(FDrive+´:\´),dLabel,12,@Serial,DirLen,Flags,nil,0);
Result := IntToHex(Serial,8);
Except Result :=´´;
end;
end;


GOSTEI 0
POSTAR