获得硬盘的ID序列号(XE10.1+WIN8.1)
获得硬盘的ID序列号(XE10.1+WIN8.1)

相关资料:
https://zhidao.baidu.com/question/195408580.html
注意事项:
1.记得右击以管理员运行。
2.SysUtils 在XE中要改为System.SysUtils。
unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Vcl.Imaging.jpeg; type
TForm1 = class(TForm)
Panel1: TPanel;
Memo1: TMemo;
Button1: TButton;
Label1: TLabel;
Image1: TImage;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} function GetScsiSerialNumber(const i: smallint): string;
type
TScsiPassThrough = record
Length: Word;
ScsiStatus: Byte;
PathId: Byte;
TargetId: Byte;
Lun: Byte;
CdbLength: Byte;
SenseInfoLength: Byte;
DataIn: Byte;
DataTransferLength: ULONG;
TimeOutValue: ULONG;
DataBufferOffset: DWORD;
SenseInfoOffset: ULONG;
Cdb: array[..] of Byte;
end;
TScsiPassThroughWithBuffers = record
spt: TScsiPassThrough;
bSenseBuf: array[..] of Byte;
bDataBuf: array[..] of Byte;
end;
var
dwReturned: DWORD;
len: DWORD;
Buffer: array[..SizeOf(TScsiPassThroughWithBuffers) + SizeOf(TScsiPassThrough) - ] of Byte;
sptwb: TScsiPassThroughWithBuffers absolute Buffer;
hDevice: thandle;
begin
Result := '';
if SysUtils.win32Platform = VER_PLATFORM_WIN32_NT then
begin
if i = then
hDevice := CreateFile('//./PhysicalDrive0',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
nil, OPEN_EXISTING, , )
else
hDevice := CreateFile('//./PhysicalDrive1',
GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE,
nil, OPEN_EXISTING, , );
end
else exit;
if hDevice = invalid_handle_value then exit;
FillChar(Buffer, SizeOf(Buffer), #);
with sptwb.spt do
begin
Length := SizeOf(TScsiPassThrough);
CdbLength := ; // CDB6GENERIC_LENGTH
SenseInfoLength := ;
DataIn := ; // SCSI_IOCTL_DATA_IN
DataTransferLength := ;
TimeOutValue := ;
DataBufferOffset := PChar(@sptwb.bDataBuf) - PChar(@sptwb);
SenseInfoOffset := PChar(@sptwb.bSenseBuf) - PChar(@sptwb);
Cdb[] := $; // OperationCode := SCSIOP_INQUIRY;
Cdb[] := $; // Flags := CDB_INQUIRY_EVPD; Vital product data
Cdb[] := $; // PageCode Unit serial number
Cdb[] := ; // AllocationLength
end;
len := sptwb.spt.DataBufferOffset + sptwb.spt.DataTransferLength;
if DeviceIoControl(hDevice, $0004D004, @sptwb, SizeOf(TScsiPassThrough), @sptwb, len, dwReturned, nil)
and ((PChar(@sptwb.bDataBuf) + )^ = #$) then
SetString(Result, PChar(@sptwb.bDataBuf) + , Ord((PChar(@sptwb.bDataBuf) + )^));
end; function GetIdeSerialNumber: pchar;
const IDENTIFY_BUFFER_SIZE = ;
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[..] of Byte;
dwReserved: array[..] of DWORD;
bBuffer: array[..] of Byte;
end;
TIdSector = packed record
wGenConfig: Word;
wNumCyls: Word;
wReserved: Word;
wNumHeads: Word;
wBytesPerTrack: Word;
wBytesPerSector: Word;
wSectorsPerTrack: Word;
wVendorUnique: array[..] of Word;
sSerialNumber: array[..] of CHAR;
wBufferType: Word;
wBufferSize: Word;
wECCSize: Word;
sFirmwareRev: array[..] of Char;
sModelNumber: array[..] 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[..] of BYTE;
end;
PIdSector = ^TIdSector;
TDriverStatus = packed record
bDriverError: Byte;
bIDEStatus: Byte;
bReserved: array[..] of Byte;
dwReserved: array[..] of DWORD;
end;
TSendCmdOutParams = packed record
cBufferSize: DWORD;
DriverStatus: TDriverStatus;
bBuffer: array[..] of BYTE;
end;
procedure ChangeByteOrder(var Data; Size: Integer);
var
ptr: Pchar;
i: Integer;
c: Char;
begin
ptr := @Data;
for I := to (Size shr ) - do begin
c := ptr^;
ptr^ := (ptr + )^;
(ptr + )^ := c;
Inc(ptr, );
end;
end;
var
hDevice: Thandle;
cbBytesReturned: DWORD;
SCIP: TSendCmdInParams;
aIdOutCmd: array[..(SizeOf(TSendCmdOutParams) + IDENTIFY_BUFFER_SIZE - ) - ] of Byte;
IdOutCmd: TSendCmdOutParams absolute aIdOutCmd;
begin
Result := '';
if SysUtils.Win32Platform = VER_PLATFORM_WIN32_NT then
// Windows NT, Windows 2000
hDevice := CreateFile('//./PhysicalDrive0', GENERIC_READ or GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE, nil, OPEN_EXISTING, , )
else
// Version Windows 95 OSR2, Windows 98
hDevice := CreateFile('//./SMARTVSD', , , nil, CREATE_NEW, , );
if hDevice = INVALID_HANDLE_VALUE then Exit;
try
FillChar(SCIP, SizeOf(TSendCmdInParams) - , #);
FillChar(aIdOutCmd, SizeOf(aIdOutCmd), #);
cbBytesReturned := ;
with SCIP do begin
cBufferSize := IDENTIFY_BUFFER_SIZE;
with irDriveRegs do begin
bSectorCountReg := ;
bSectorNumberReg := ;
bDriveHeadReg := $A0;
bCommandReg := $EC;
end;
end;
if not DeviceIoControl(hDevice, $0007C088, @SCIP, SizeOf(TSendCmdInParams) - ,
@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))^ := #;
Result := Pchar(@sSerialNumber);
end;
end; procedure TForm1.Button1Click(Sender: TObject);
var
stmp:String;
begin
//记得右击以管理员运行
stmp := StrPas(PAnsiChar(GetIdeSerialNumber));
if stmp<>'' then
begin
Memo1.Lines.Add('无参:' + stmp);
end
else
begin
stmp := Trim(GetScsiSerialNumber());
Memo1.Lines.Add('有参:' + stmp);
end;
end; end.
获得硬盘的ID序列号(XE10.1+WIN8.1)的更多相关文章
- java+redis+lua生成自动增长的ID序列号
1.编写lua脚本用于生成主键ID序列号,内容如下 local key = tostring(KEYS[1]); local count = tonumber(KEYS[2]); local date ...
- C# 获取U盘ID序列号及U盘信息
C# 获取U盘ID序列号及U盘信息 2011-05-20 上传大小:35KB c#VS2005U盘IDU盘信息 获取U盘ID序列号 VS2005编译通过,源码源自CSDN.已经测试好用. 可以获得 ...
- linux 下查看硬件信息(mac,IP地址,硬盘型号,序列号等)
一.查看网卡mac地址 #安装lshw [root@server ~]# yum install lshw #使用方法 [root@rsync-server ~]# lshw -c network * ...
- 屏幕亮度(XE10.1+WIN8.164)
相关资料: http://bbs.csdn.net/topics/390664310 实例代码: unit Unit1; interface uses Winapi.Windows, Winapi.M ...
- 屏幕相关操作(XE10.1+WIN8.164)
相关资料: http://www.bianceng.cn/Programming/Delphi/201104/25455.htm http://blog.csdn.net/anbangs/articl ...
- asp.net中获取本机的相关信息!(CPU、内存、硬盘序列号等)
// 注意:首先要在项目bin目录中添加引用 System.Management using System;using System.Collections.Generic;using System. ...
- 获得服务器硬件信息(CPUID、硬盘号、主板序列号、IP地址等)
1 // 注意:首先要在项目中添加引用 System.Management using System; using System.Collections.Generic; using System.L ...
- 【miscellaneous】如何利用硬盘号和CPU序列号为软件加密
原文:http://www.jiamisoft.com/blog/index.php/3469-yingpanhaocpuruanjianjiami.html 计算机软件是一种特殊的产品,为了防止软件 ...
- ThinkPad告别蓝快,自己使用VHD安 WIN8.1并成功激活
写在前面:本文WIN8.1激活适合于中国大陆地区国行预装WIN8系统(bios写入WIN8授权)是可激活的,享受正版WIN8系统(同样可以安装WIN8.1系统).比如联想的Y400.Y500.Y480 ...
随机推荐
- Musle比对软件
下载地址:http://www.drive5.com/muscle/downloads.htm 1)运行: win+R然后输入cmd,然后cd进入muscle目录 2) 比对: muscle3.8.3 ...
- .net 发送邮件失败
1,是否为企业邮箱,如果是则用最高admin的帐号,降低其安全级别,下面的子帐号自动适用.(Google 阻止了从某个不够安全的应用进行的登录尝试) 2,做一个测试页面,对错误结果进行分析,一步一步查 ...
- 关于number...的精度问题
一 当数字的精度被定为number(3,2)时, 这时他能输入的数字整数部分只能是3-2=1位, 小数位如果不够会用0补齐, 超出的四舍五入保留3位小数. SQL> insert into t_ ...
- nyoj86-找球号(一) 【set 二分查找 hash】
http://acm.nyist.net/JudgeOnline/problem.php?pid=86 找球号(一) 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 ...
- 动态调用WebService方法
好像很多人做WebService的时候都是直接添加引用的方式,然后调用服务端的方法.这样就个问题,就是每次我服务端添加了方法或者修改了方法后都要更新Web引用,这样比较麻烦.下面给一个不用添加引用 ...
- viewstamp replication: A new primary copy method to support highly-avaliable d
为了提高服务能力或者服务稳定,往往需要把数据重复布署,也就是replication.重复带来的问题是,更新的时候会带来不一致.一种比较简单的方法是,在N台重复的机器里选一台作为主机,其他作备份,只能通 ...
- 运行代码后出现Process finished with exit code 0是为什么?
Process finished with exit code 0 意味着你的程序正常执行完毕并退出. 可以科普一下exit code,在大部分编程语言中都适用: exit code 0 表示程序执行 ...
- ANT发送邮件需要的3个JAR包
ANT发送邮件需要的3个JAR包:activation.jar.mail.jar.commons-email-1.2.jar 将这三个jar包放到 $ANT_HOME/LIB 路径下即可 内网发送邮件 ...
- pyqt5和qtdesign的使用
http://blog.csdn.net/Angelasan/article/details/44917283 发现我的使用时候有点跟他不同. 我是 g: utf- -*- # Form implem ...
- Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses.
解决方法: <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-m ...