Einzelnen Beitrag anzeigen

Daniel B
(Gast)

n/a Beiträge
 
#7
  Alt 28. Jun 2002, 20:25
Hier ist mal meine Prozedur um Daten aus der Reg zu Lesen. Ich lade sie aber in eine Stringlist und weise sie dann der einen Combo zu. Du musst es halt noch anpassen. Vielleicht bringts dir ja was.

Code:
procedure TEinstellungen.FormShow(Sender: TObject);
//ComPorts ermitteln und in ComboBox Anzeigen
var
  reg: TRegistry;
  st: TStrings;
  i: integer;
  ini: TIniFile;
  s: string;
begin
  ShowMessage('Bei änderungen, kann gleich mit den neuen Werten weiter gearbeitet'
    + #13 + 'werden. Das Programm muss nicht neu gestartet werden!');
  reg := TRegistry.Create;
  reg.RootKey := HKEY_LOCAL_MACHINE;
  reg.OpenKey('hardware\devicemap\serialcomm', False);
  st := TStringList.Create;
  reg.GetValueNames(st);
  ComboBoxPort.Items.Clear;
  for i := 0 to st.Count -1 do
    begin
      ComboBoxPort.Items.Add(reg.ReadString(st.Strings[i]));
    end;
  st.Free;
  reg.CloseKey;
  reg.free;
  if MainFormMC2004.ComPort.Port = 'COM1' then
  begin
    ComboBoxPort.ItemIndex := 0;
  end
  else if MainFormMC2004.ComPort.Port = 'COM2' then
  begin
    ComboBoxPort.ItemIndex := 1;
  end
  else if MainFormMC2004.ComPort.Port = 'COM3' then
  begin
    ComboBoxPort.ItemIndex := 2;
  end
  else if MainFormMC2004.ComPort.Port = 'COM4' then
  begin
    ComboBoxPort.ItemIndex := 3;
  end
  else if MainFormMC2004.ComPort.Port = 'COM5' then
  begin
    ComboBoxPort.ItemIndex := 4;
  end
  else if MainFormMC2004.ComPort.Port = 'COM6' then
  begin
    ComboBoxPort.ItemIndex := 5;
  end
  else if MainFormMC2004.ComPort.Port = 'COM7' then
  begin
    ComboBoxPort.ItemIndex := 6;
  end
  else if MainFormMC2004.ComPort.Port = 'COM8' then
  begin
    ComboBoxPort.ItemIndex := 7;
  end;
  ini:=TIniFile.Create(ChangeFileExt(ParamStr(0), '.ini'));
  try
    s := ini.ReadString('Einstellungen', 'Baud', '');
  finally
    ini.Free;
  end;
  if s = '2400' then
  begin
    ComboBoxBaud.ItemIndex := 0;
  end
  else if s = '4800' then
  begin
    ComboBoxBaud.ItemIndex := 1;
  end
  else if s = '9600' then
  begin
    ComboBoxBaud.ItemIndex := 2;
  end
  else if s = '14400' then
  begin
    ComboBoxBaud.ItemIndex := 3;
  end
  else if s = '19200' then
  begin
    ComboBoxBaud.ItemIndex := 4;
  end
  else if s = '28800' then
  begin
    ComboBoxBaud.ItemIndex := 5;
  end
  else if s = '38400' then
  begin
    ComboBoxBaud.ItemIndex := 6;
  end;  
end;
  Mit Zitat antworten Zitat