获取硬盘号(15分)

  • 主题发起人 主题发起人 supershan
  • 开始时间 开始时间
S

supershan

Unregistered / Unconfirmed
GUEST, unregistred user!
谁知道获取硬盘号的函数请举例!
 
>> function GetHDSerialNumber: LongInt;

> Description : Get the Serial Number of the Hard Disk where the Key File
lives.

> Input : none

> Output : Returns Serial Number of disk where is fKeyFileName
if success or -1 on error.
> Notes : This only returns SerialNumber under Win 95/NT, for
: win 3.1, I am using GetWinFlags which returns a LongInt
: that contains CPU and Mode information. Not as good, but
: far more reliable than trying to query the HD information
: from Win 3.1

==============================}
function GetHDSerialNumber: LongInt;
{$IFDEF WIN32}
var
pdw : pDWord;
mc, fl : dword;
{$ENDIF}
begin
{$IfDef WIN32}
New(pdw);
GetVolumeInformation(nil,nil,0,pdw,mc,fl,nil,0);
Result := pdw^;
dispose(pdw);
{$ELSE}
Result := GetWinFlags;
{$ENDIF}
end;

试试吧
 
接受答案了.
 
后退
顶部