下面这个函数如何可以使用:
function GetHardwardIDs(const Drive: Char): string;
var
  Buffer: array[0..MAX_PATH- 1] of Char;
  hDevInst, DevInstParent: DEVINST;
  Num: Integer;
begin
  Result := '';
  
  //根据设备取得设备号
  Num := GetDeviceNumberByDrive(Drive);
  if Num = -1 then Exit;  hDevInst := GetDevInstByNum(Num);
  if hDevInst = INVALID_HANDLE_VALUE then Exit;
    FillChar(Buffer, MAX_PATH, 0);
  CM_Get_Parent(DevInstParent, hDevInst, 0);
  CM_Get_Device_ID(DevInstParent, Buffer, MAX_PATH, 0);
  
  Result := StrPas(Buffer);
end;
GetHardwardIDs(Drive);