I have function in delphi
function GetHardDiskSerial(const DriveLetter: Char): string;varNotUsed: DWORD;VolumeFlags: DWORD;VolumeInfo: array[0..MAX_PATH] of Char;VolumeSerialNumber: DWORD;beginGetVolumeInformation(PChar(DriveLetter + ':\'),nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed,VolumeFlags, nil, 0);Result := Format('%8.8X',[VolumeSerialNumber])end;
how to take the outputcharacter to 2 up to 4.
Example: 7121334
- Result must be: 121
cSerial.text=......................................
Best 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.