I have function in delphi
function GetHardDiskSerial(const DriveLetter: Char): string; var NotUsed: DWORD; VolumeFlags: DWORD; VolumeInfo: array[0..MAX_PATH] of Char; VolumeSerialNumber: DWORD; begin GetVolumeInformation(PChar(DriveLetter + ':\'), nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed, VolumeFlags, nil, 0); Result := Format('%8.8X', [VolumeSerialNumber]) end; how to take the output character to 2 up to 4.
Example: 7121334
- Result must be: 121
cSerial.text=......................................
1 Answer
You can use the Copy function to extract a sequence of characters from a string:
cSerial.Text := Copy(Result, 2, 3); Note that the third parameter is the number of characters to extract, not the index of the last character.
1