请大家讨论一下,有哪些硬件信息是唯一的?(比如硬盘序列号),又怎样获得呢?主要是用于软件保互。谢谢!!(100分)

  • 主题发起人 主题发起人 cxling03
  • 开始时间 开始时间
C

cxling03

Unregistered / Unconfirmed
GUEST, unregistred user!
请大家讨论一下,有哪些硬件信息是唯一的?(比如硬盘序列号),又怎样获得呢?主要是用于软件保互。谢谢!!
 
Mac网卡地址,方法找找网站资料有的
 
获取所有的系统信息
http://www.mitec.cz/Downloads/MSIC.zip
 
很多软件都用mac.要保护,还是用狗比较好.
 
下面的代码是限盘盘序列号,希望对你有用!
给分吧!
function GetIdeSerialNumber : pchar;
const IDENTIFY_BUFFER_SIZE = 512;
type
TIDERegs = packed record
bFeaturesReg : BYTE;
bSectorCountReg : BYTE;
bSectorNumberReg : BYTE;
bCylLowReg : BYTE;
bCylHighReg : BYTE;
bDriveHeadReg : BYTE;
bCommandReg : BYTE;
bReserved : BYTE;
end;
TSendCmdInParams = packed record

cBufferSize : DWORD;

irDriveRegs : TIDERegs;

bDriveNumber : BYTE;
bReserved : Array[0..2] of Byte;
dwReserved : Array[0..3] of DWORD;
bBuffer : Array[0..0] of Byte;
end;
TIdSector = packed record
wGenConfig : Word;
wNumCyls : Word;
wReserved : Word;
wNumHeads : Word;
wBytesPerTrack : Word;
wBytesPerSector : Word;
wSectorsPerTrack : Word;
wVendorUnique : Array[0..2] of Word;
sSerialNumber : Array[0..19] of CHAR;
wBufferType : Word;
wBufferSize : Word;
wECCSize : Word;
sFirmwareRev : Array[0..7] of Char;
sModelNumber : Array[0..39] of Char;
wMoreVendorUnique : Word;
wDoubleWordIO : Word;
wCapabilities : Word;
wReserved1 : Word;
wPIOTiming : Word;
wDMATiming : Word;
wBS : Word;
wNumCurrentCyls : Word;
wNumCurrentHeads : Word;
wNumCurrentSectorsPerTrack : Word;
ulCurrentSectorCapacity : DWORD;
wMultSectorStuff : Word;
ulTotalAddressableSectors : DWORD;
wSingleWordDMA : Word;
wMultiWordDMA : Word;
bReserved : Array[0..127] of BYTE;
end;
PIdSector = ^TIdSector;
TDriverStatus = packed record
bDriverError : Byte;
bIDEStatus : Byte;
bReserved : Array[0..1] of Byte;
dwReserved : Array[0..1] of DWORD;
end;
TSendCmdOutParams = packed record
cBufferSize : DWORD;
DriverStatus : TDriverStatus;
bBuffer : Array[0..0] of BYTE;
end;
var hDevice : THandle;
cbBytesReturned : DWORD;
ptr : PChar;
SCIP : TSendCmdInParams;
aIdOutCmd : Array [0..(SizeOf(TSendCmdOutParams)+IDENTIFY_BUFFER_SIZE-1)-1] of Byte;
IdOutCmd : TSendCmdOutParams absolute aIdOutCmd;
procedure ChangeByteOrder( var Data; Size : Integer );
var ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1 do begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;
begin
Result := '';
if SysUtils.Win32Platform=VER_PLATFORM_WIN32_NT then begin// Windows NT, Windows 2000
hDevice := CreateFile( '//./PhysicalDrive0', GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
end else
hDevice := CreateFile( '//./SMARTVSD', 0, 0, nil, CREATE_NEW, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then Exit;
try
FillChar(SCIP,SizeOf(TSendCmdInParams)-1,#0);
FillChar(aIdOutCmd,SizeOf(aIdOutCmd),#0);
cbBytesReturned := 0;
with SCIP do begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
with irDriveRegs do begin
bSectorCountReg := 1;
bSectorNumberReg := 1;
bDriveHeadReg := $A0;
bCommandReg := $EC;
end;
end;
if not DeviceIoControl( hDevice, $0007c088, @SCIP, SizeOf(TSendCmdInParams)-1,
@aIdOutCmd, SizeOf(aIdOutCmd), cbBytesReturned, nil ) then Exit;
finally
CloseHandle(hDevice);
end;
with PIdSector(@IdOutCmd.bBuffer)^ do begin
ChangeByteOrder( sSerialNumber, SizeOf(sSerialNumber) );
(PChar(@sSerialNumber)+SizeOf(sSerialNumber))^ := #0;
Result := PChar(@sSerialNumber);
end;
end;
 
function GetIdeDiskSerialNumber : String;
type
TSrbIoControl = packed record
HeaderLength : ULONG;
Signature : Array[0..7] of Char;
Timeout : ULONG;
ControlCode : ULONG;
ReturnCode : ULONG;
Length : ULONG;
end;
SRB_IO_CONTROL = TSrbIoControl;
PSrbIoControl = ^TSrbIoControl;

TIDERegs = packed record
bFeaturesReg : Byte; // Used for specifying SMART "commands".
bSectorCountReg : Byte; // IDE sector count register
bSectorNumberReg : Byte; // IDE sector number register
bCylLowReg : Byte; // IDE low order cylinder value
bCylHighReg : Byte; // IDE high order cylinder value
bDriveHeadReg : Byte; // IDE drive/head register
bCommandReg : Byte; // Actual IDE command.
bReserved : Byte; // reserved for future use. Must be zero.
end;
IDEREGS = TIDERegs;
PIDERegs = ^TIDERegs;

TSendCmdInParams = packed record
cBufferSize : DWORD; // Buffer size in bytes
irDriveRegs : TIDERegs; // Structure with drive register values.
bDriveNumber : Byte; // Physical drive number to send command to (0,1,2,3).
bReserved : Array[0..2] of Byte; // Reserved for future expansion.
dwReserved : Array[0..3] of DWORD; // For future use.
bBuffer : Array[0..0] of Byte; // Input buffer.
end;
SENDCMDINPARAMS = TSendCmdInParams;
PSendCmdInParams = ^TSendCmdInParams;

TIdSector = packed record
wGenConfig : Word;
wNumCyls : Word;
wReserved : Word;
wNumHeads : Word;
wBytesPerTrack : Word;
wBytesPerSector : Word;
wSectorsPerTrack : Word;
wVendorUnique : Array[0..2] of Word;
sSerialNumber : Array[0..19] of Char;
wBufferType : Word;
wBufferSize : Word;
wECCSize : Word;
sFirmwareRev : Array[0..7] of Char;
sModelNumber : Array[0..39] of Char;
wMoreVendorUnique : Word;
wDoubleWordIO : Word;
wCapabilities : Word;
wReserved1 : Word;
wPIOTiming : Word;
wDMATiming : Word;
wBS : Word;
wNumCurrentCyls : Word;
wNumCurrentHeads : Word;
wNumCurrentSectorsPerTrack : Word;
ulCurrentSectorCapacity : ULONG;
wMultSectorStuff : Word;
ulTotalAddressableSectors : ULONG;
wSingleWordDMA : Word;
wMultiWordDMA : Word;
bReserved : Array[0..127] of Byte;
end;
PIdSector = ^TIdSector;

const
IDE_ID_FUNCTION = $EC;
IDENTIFY_BUFFER_SIZE = 512;
DFP_RECEIVE_DRIVE_DATA = $0007c088;
IOCTL_SCSI_MINIPORT = $0004d008;
IOCTL_SCSI_MINIPORT_IDENTIFY = $001b0501;
DataSize = sizeof(TSendCmdInParams)-1+IDENTIFY_BUFFER_SIZE;
BufferSize = SizeOf(SRB_IO_CONTROL)+DataSize;
W9xBufferSize = IDENTIFY_BUFFER_SIZE+16;
var
hDevice : THandle;
cbBytesReturned : DWORD;
pInData : PSendCmdInParams;
pOutData : Pointer; // PSendCmdInParams;
Buffer : Array[0..BufferSize-1] of Byte;
srbControl : TSrbIoControl absolute Buffer;

procedure ChangeByteOrder( var Data; Size : Integer );
var ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1 do
begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;

begin
Result := '';
FillChar(Buffer,BufferSize,#0);
if Win32Platform=VER_PLATFORM_WIN32_NT then
begin // Windows NT, Windows 2000
// Get SCSI port handle
hDevice := CreateFile( '//./Scsi0:', GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then Exit;
try
srbControl.HeaderLength := SizeOf(SRB_IO_CONTROL);
System.Move('SCSIDISK',srbControl.Signature,8);
srbControl.Timeout := 2;
srbControl.Length := DataSize;
srbControl.ControlCode := IOCTL_SCSI_MINIPORT_IDENTIFY;
pInData := PSendCmdInParams(PChar(@Buffer)+SizeOf(SRB_IO_CONTROL));
pOutData := pInData;
with pInData^ do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := 0;
with irDriveRegs do
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0;
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, IOCTL_SCSI_MINIPORT, @Buffer, BufferSize, @Buffer, BufferSize, cbBytesReturned, nil ) then Exit;
finally
CloseHandle(hDevice);
end;
end
else
begin // Windows 95 OSR2, Windows 98
hDevice := CreateFile( '//./SMARTVSD', 0, 0, nil, CREATE_NEW, 0, 0 );
if hDevice=INVALID_HANDLE_VALUE then Exit;
try
pInData := PSendCmdInParams(@Buffer);
pOutData := PChar(@pInData^.bBuffer);
with pInData^ do
begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
bDriveNumber := 0;
with irDriveRegs do
begin
bFeaturesReg := 0;
bSectorCountReg := 1;
bSectorNumberReg := 1;
bCylLowReg := 0;
bCylHighReg := 0;
bDriveHeadReg := $A0;
bCommandReg := IDE_ID_FUNCTION;
end;
end;
if not DeviceIoControl( hDevice, DFP_RECEIVE_DRIVE_DATA, pInData, SizeOf(TSendCmdInParams)-1, pOutData, W9xBufferSize, cbBytesReturned, nil ) then Exit;
finally
CloseHandle(hDevice);
end;
end;
with PIdSector(PChar(pOutData)+16)^ do
begin
ChangeByteOrder(sSerialNumber,SizeOf(sSerialNumber));
SetString(Result,sSerialNumber,SizeOf(sSerialNumber));
end;
end;
上面的方法在95,98下要将system下的smartvsd.vxd先复制到Windows 的IOSUBSYS目录下,
重新启动后才可以使用。不知道你是否介意用dll,我试过一些dll,好像都可以的。
 
谢谢各位的帮助!!
我用下列方法,为什么会得四个网卡地址.我的机器只有一个网卡啊.结果却为:
00-50-01-00-29-89
F4-71-20-52-41-53
F2-E8-20-52-41-53
F2-E8-20-52-41-53
00-50-01-00-29-89
代码:
procedure n1(Strings:TStrings);
function HexBL(by:Byte):String;
begin
Result:=Format('%X',[by]);
if Length(Result)<2 then
Result:='0'+Result;
end;
var
NCB:TNCB;
Adapter:TAdapterStatus;
LanaEnum:TLanaEnum;
i,j:integer;
Str:String;
begin
Strings.Clear;
ZeroMemory(@NCB,Sizeof(NCB));
NCB.ncb_command:=Chr(NCBEnum);
NetBios(@NCB);
NCB.ncb_buffer:=@LanaEnum;
NCB.ncb_length:=Sizeof(LanaEnum);
NCB.ncb_command:=Chr(NCBEnum);
NetBios(@NCB);
for i:=0 to ord(LanaEnum.Length)-1 do
begin
ZeroMemory(@NCB,Sizeof(NCB));
NCB.ncb_command:=Chr(NCBReset);
NCB.ncb_lana_num:=LanaEnum.lana;
NetBios(@NCB);
ZeroMemory(@NCB,Sizeof(NCB));
NCB.ncb_command:=Chr(NCBASTAT);//发送NetBios()NCBASTAT命令
NCB.ncb_lana_num:=LanaEnum.lana;
StrPCopy(NCB.ncb_callname,'*');
NCB.ncb_buffer:=@Adapter;
NCB.ncb_length:=Sizeof(Adapter);
NetBios(@NCB);
Str:='';
for j:=0 to 5 do
begin
if j>0 then Str:=Str+'-';
Str:=Str+HexBL(Byte(Adapter.Adapter_Address[j]));
end;
Strings.Add(Str);
end;
end;

 
http://bbs.zglong.com/
 
谢谢各位朋友的热情帮助,请问怎样才能取得主板序列号,下面的方法不行。
FSerial := String(Pchar(Ptr($FEC71)));
 
如何获取硬盘的ID



function GetHDSerialNumber(Drv : String): String;

var

VolumeSerialNumber : DWORD;

MaximumComponentLength : DWORD;

FileSystemFlags : DWORD;

begin

if Drv[Length(Drv)] =':' then Drv := Drv + '/';

GetVolumeInformation(pChar(Drv)


nil


0


@VolumeSerialNumber


MaximumComponentLength


FileSystemFlags


MaximumComponentLength : DWORD;

FileSystemFlags : DWORD;

begin

if Drv[Length(Drv)] =':' then Drv := Drv + '/';

GetVolumeInformation(pChar(Drv)


nil


0


@VolumeSerialNumber


MaximumComponentLength


nil

SystemFlags


0);

Result := IntToHex(HiWord(VolumeSerialNumber)

4) +

'-' +

IntToHex(LoWord(VolumeSerialNumber)

4);

end;
 
我刚试过,不用修改,只需声明就可以的

function GetHardDiskKey:string; //获取硬盘序列号
var
pdw : pDWord;
mc, fl : dword;
begin
New(pdw);
GetVolumeInformation(pchar('C:/'),nil,0,pdw,mc,fl,nil,0);
result := inttostr(pdw^);
dispose(pdw);
end;
 
GetVolumeInformation是错的!
 
以上取硬盘序列号的方法我基本上都试过,一般都有问题,要么是不能在win98/2000下都能用,要么是只能取IDE硬盘的,不能取SCSI的。
取主板序列号的,一般在台式机上还可以,在笔记本上就不行了。要么取不出来,要么是乱码。

能解决以上问题的方法,直到现在还没有找到!
 
谢谢各位朋友的热情参与.不过到现在还没有一个完美的结果,我想取主板序列号是最好的.
 
http://delphi.freemai.com/list.asp?id=659
文件名称 获得硬盘序列号的源码
文件类型 系统编程
运行环境 Win9x/WinNT/Win2000/WinME
去看看??
 
http://www.playicq.com/dispdocnew.php?id=10151

ftp://new:new12345@61.129.70.192:2100/control/200311031302002140.rar


用于软件保护
 
老友,我发了个带原码的控件到你信箱里。
 
接受答案了.
 

Similar threads

后退
顶部