- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在使用 Inno Setup 创建的安装过程中,我需要获取驱动器号的卷序列号。我知道可以将 DLL 函数导入 Inno,但我对它很陌生,并且在使其工作时遇到了一些问题。我知道 kernel32 中的 GetVolumeInformation 函数可以做我需要的。有人可以告诉我如何在 Inno 脚本中导入和使用该功能来检索卷序列号吗?
谢谢!
最佳答案
Inno-Setup 代码::
[Code]
function GetVolumeInformation(
lpRootPathName: PChar;
lpVolumeNameBuffer: PChar;
nVolumeNameSize: DWORD;
var lpVolumeSerialNumber: DWORD;
var lpMaximumComponentLength: DWORD;
var lpFileSystemFlags: DWORD;
lpFileSystemNameBuffer: PChar;
nFileSystemNameSize: DWORD
): BOOL;
external 'GetVolumeInformationA@kernel32.dll stdcall';
function LoWord(dw: DWORD): WORD;
begin
Result := WORD(dw);
end;
function HiWord(dw: DWORD): WORD;
begin
Result := WORD((dw shr 16) and $FFFF);
end;
function WordToHex(w: WORD): string;
begin
Result := Format('%.4x', [w]);
end;
function FindVolumeSerial(const Drive: string): string;
var
FileSystemFlags: DWORD;
VolumeSerialNumber: DWORD;
MaximumComponentLength: DWORD;
begin
Result := '';
// Note on passing PChars using RemObjects Pascal Script:
// '' pass a nil PChar
// #0 pass an empty PChar
if GetVolumeInformation(
PChar(Drive),
'', // nil
0,
VolumeSerialNumber,
MaximumComponentLength,
FileSystemFlags,
'', // nil
0)
then
Result := WordToHex(HiWord(VolumeSerialNumber)) + '-' + WordToHex(LoWord(VolumeSerialNumber));
end;
function InitializeSetup(): Boolean;
begin
MsgBox(FindVolumeSerial('c:\'), mbInformation, mb_Ok);
end;
PChar
与
PAnsiChar
关于winapi - 如何在 Inno Setup 中使用 GetVolumeInformation?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9272308/
DWORD disk_serialINT[MAX_PATH + 1]; GetVolumeInformationA(NULL, NULL, NULL, disk_serialINT, NULL, NU
我想为我正在编写的程序获取特定驱动器(FAT32、NTFS、FAT16)的文件系统类型。但是当我运行这段代码时,我在 szFileSystemName 变量中得到看似随机的结果。非常感谢任何帮助。 #
MSDN documentation和 knowledge base article GetVolumeInformation 不是很具体文件系统名称字符串可以包含什么。 明显的值是 NTFS、CDF
在使用 Inno Setup 创建的安装过程中,我需要获取驱动器号的卷序列号。我知道可以将 DLL 函数导入 Inno,但我对它很陌生,并且在使其工作时遇到了一些问题。我知道 kernel32 中的
你好, 我使用 GetLogicalDrives 获取所有驱动器,我想进一步使用它来检测驱动器类型,然后使用 GetVolumeInformation 检查特定驱动器的状态。但是,我无法在 GetVo
我正在尝试使用 Detours Express (3.0) Hook GetVolumeInformation,以更改音量序列。问题是每次调用 Hook 函数时,它都会返回一个随机卷序列。 #incl
我想使用 GetVolumeInformation 调用来检索可移动设备的名称。我可以很好地检索名称并将其存储到 TCHAR 数组变量 szVolNameBuff 中。这是我的代码: // Get
在使用 GetVolumeInformation() 报告的 FILE_READ_ONLY_VOLUME 文件系统标志检查 SD 卡是否被锁定时,我得到了一些奇怪的结果. 如果 SD 卡被锁定,并且
我是一名优秀的程序员,十分优秀!