Skip to content

Instantly share code, notes, and snippets.

@Brutt
Created July 10, 2017 10:18
Show Gist options
  • Save Brutt/fe145c97437decf552ca18e150d66b1c to your computer and use it in GitHub Desktop.
Save Brutt/fe145c97437decf552ca18e150d66b1c to your computer and use it in GitHub Desktop.
Get the list of available COM-ports from Windows Registry
uses Registry;
procedure getCOM_ports();
var
reg: TRegistry;
st: Tstrings;
begin
reg := TRegistry.Create(KEY_READ);
try
reg.RootKey := HKEY_LOCAL_MACHINE;
reg.OpenKey('hardware\devicemap\serialcomm', False);
st := TstringList.Create;
try
reg.GetValueNames(st);
for i := 0 to st.Count - 1 do
begin
ShowMessage(reg.Readstring(st.strings[i]));
end;
finally
st.Free;
end;
reg.CloseKey;
finally
reg.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment