[Lazarus] Lazarus does not find compiled package, why?

Werner Pamler werner.pamler at freenet.de
Mon Oct 31 00:32:50 CET 2022


Am 30.10.2022 um 19:42 schrieb Bo Berglund via lazarus
> When I am at it:
> Is there a way on Windows to enumerate the existing serial ports so I can put a
> selector list on the form?

I have the following code in one of my projects (Windows-only). It 
creates a comma-separated list to assigned to a ComboBox.Items.CommaText

function GetSerialPortNames: string;
var
   reg: TRegistry;
   l, v: TStringList;
   n: integer;
begin
   l := TStringList.Create;
   v := TStringList.Create;
   reg := TRegistry.Create;
   try
     reg.Access := KEY_READ;
     reg.RootKey := HKEY_LOCAL_MACHINE;
     reg.OpenKey('\HARDWARE\DEVICEMAP\SERIALCOMM', false);
     reg.GetValueNames(l);
     for n := 0 to l.Count - 1 do
       v.Add(PChar(reg.ReadString(l[n])));
     Result := v.CommaText;
   finally
     reg.Free;
     l.Free;
     v.Free;
   end;
end;



More information about the lazarus mailing list