serial port properties lazarus / 34-Windows ---------------------------------------------------------------------- Rik · 2025-08-05 11:13 Elsewhere in this forum (https://forum.lazarus.freepascal.org/index.ph p/topic,16616.msg90544.html#msg90544) I found a script that return the friendly name of a serial port via the Windows Registry. The friendly name is retrieved using the TRegistry.ReadString('FriendlyName') function. I would expect that it is possible to retrieve other serial port properties as wel via the ReadString function? With properties I mean those that can be found via the Device Manager -> Ports (COM & LPT)-> Device -> Properties -> Details. As a quick and dirty test I tried to get the Device description using TRegistry.ReadString('DeviceDescription'), but that failed. Is it possible to retrieve other properties as wel via the ReadString function? If so, where can I find a list of the strings to be used and the corresponding properties? . ---------------------------------------------------------------------- gues1 · 2025-08-05 13:15 All Hardware properties (where settings were maintained) are described in the key: HKLM/System/CurrentControlSet/Enum But more subkey are locked (you neede special auth to access them, admin is not enough). You can access to these data and more via WMI interface, here one example: https://theroadtodelphi.com/category/wmi/ For serial port you can also open all of them and read directly the properties, but you will not know the limits (for example maximun baud rates supported). ---------------------------------------------------------------------- Rik · 2025-08-05 13:54 QuoteAll Hardware properties (where settings were maintained) are described in the key: HKLM/System/CurrentControlSet/EnumIndeed, but I already tried that ... QuoteBut more subkey are locked (you neede special auth to access them, admin is not enough).. and got stuck on an access denied error for the subkey Properties, even with admin privileges. QuoteYou can access to these data and more via WMI interfaceThat's new stuff to me, I'll have a look at it. ---------------------------------------------------------------------- Rik · 2025-08-08 10:49 WMI is not needed for what I was looking for. The funcion TRegistry.GetValueNames: TUnicodeStringArray returns the names of all available properties of the serial port. ---------------------------------------------------------------------- CM630 · 2025-08-08 11:42 I use this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function GetComFriendlyName (PortName : string) : String;var  Registry : TRegistry;  PortType: String = '';  VID_PID: String = '';  ID: string = '';  Contents : array of String;  KeyName: String = '';begin  Result := '';  Registry := TRegistry.Create(KEY_READ);  try    Registry.RootKey := HKEY_LOCAL_MACHINE;    if Registry.OpenKey('\SYSTEM\ControlSet001\Control\COM Name Arbiter\Devices',False) then    begin      Contents := Registry.ReadString(PortName).Split(['#']);      if (Length(Contents) > 2) then      begin        PortType := copy(Contents[0],5,MaxInt) ;      VID_PID := Contents[1];        ID := Contents[2];        KeyName := '\SYSTEM\ControlSet001\Enum\' + PortType + '\' + VID_PID + '\' + ID;        if Registry.OpenKey(KeyName,False) then          Result := Registry.ReadString('FriendlyName');      end; //Length    end; //if Registry.OpenKey  finally    Registry.Free;  end; //tryend; procedure TForm1.FormCreate(Sender: TObject);begin  ShowMessage (GetComFriendlyName('COM51'));end; I get the port names from GetSerialPortNames, which is a routine of the multiplatform TLazSerial. How to get friendly names in Linux (if they exist) - I do not know. ---------------------------------------------------------------------- gues1 · 2025-08-08 13:18 Quote from: Rik on August 08, 2025, 12:49:33 pmWMI is not needed for what I was looking for. The funcion TRegistry.GetValueNames: TUnicodeStringArray returns the names of all available properties of the serial port. Good to know. ---------------------------------------------------------------------- jamie · 2025-09-13 14:27 https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf- winbase-getcommports states you need windows 10 min. so just an idea.. Jamie ---------------------------------------------------------------------- Jurassic Pork · 2025-09-13 23:07 Quote from: Rik on August 08, 2025, 12:49:33 pmWMI is not needed for what I was looking for. Hello, Maybe : it is what you are looking for  With this code , i can retrieve some properties of my Serial ports on Windows 11 with Lazarus 3.6 . Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i implementationuses contnrs,utilwmi;{$R *.lfm}{ TForm1 } procedure TForm1.Button5Click(Sender: TObject);var  WMIResult         : TFPObjectList;  i                 : Integer;  PropNamesIndex    : Integer;  PropNames         : Array[0..4] of String =                    ( 'Manufacturer','Caption','Name',                        'Description','DeviceID');  PropName       : String;  PropValue      : String;begin    WMIResult := GetWMIInfo('Win32_PnPEntity', PropNames,                 'Where PnpClass = ''Ports'' ');                 // 'Where Name LIKE ''%(COM%'' ');  for i := 0 to Pred(WMIResult.Count) do  begin    Memo1.Append('================================================');    for PropNamesIndex := Low(PropNames) to High(PropNames) do    begin    PropName :=   TStringList(WMIResult[i]).Names[PropNamesIndex];      PropValue :=   TStringList(WMIResult[i]).ValueFromIndex[PropNamesIndex];      Memo1.Append(PropName + ' : ' +              PropValue);    end;  end;  // Clean up  WMIResult.Free;end;  QuoteManufacturer : FTDI Caption : USB Serial Port (COM5) Name : USB Serial Port (COM5) Description : USB Serial Port DeviceID : FTDIBUS\VID_0403+PID_6001+6&1FEC562&7&1\0000 ================================================ Manufacturer : FTDI Caption : USB Serial Port (COM6) Name : USB Serial Port (COM6) Description : USB Serial Port DeviceID : FTDIBUS\VID_0403+PID_6001+6&1FEC562&7&2\0000 In attachment in a zip file my utility  utilwmi. Not sure that it is OK with "Hardware serial ports" (not USB - i can't check) . Friendly, J.P