{获得磁盘驱动器序列号}
function Get_HD_Serial(const Drivedir: Char): string; var Nu: DWORD; Vf: DWORD; VolumeInfo: array[0..MAX_PATH] of Char; V_n: DWORD; begin GetVolumeInformation(PChar(Drivedir + ':\'), nil, SizeOf(VolumeInfo), @V_n,Nu, Vf, nil, 0); Result := Format('%x-%x',[HiWord(V_n),LoWord(V_n)]); // Result := Format('%8.0X', [V_n]) end; //格式化硬盘卷标ID号会改变
调用
Caption:=Get_HD_Serial('c') ;