C
Castle
Unregistered / Unconfirmed
GUEST, unregistred user!
// read reg get com name
procedure TFrmMain.FormCreate(Sender: TObject);
var
reg:TRegistry; //ÉùÃ÷Ò»¸öTRegistryÀà±äÁ¿
st: Tstrings;
i: Integer;
j: Integer;
pcpt: string;
begin
reg := TRegistry.Create;
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
pcpt:=Trim(reg.Readstring(st.strings));
// RadioGroup disable
for j := 0 to 7 do
begin
if RdGrpComName.Items[j] = pcpt then
Self.RdGrpComName.Controls[j].Enabled := true
else
begin
Self.RdGrpComName.Controls[j].Enabled := false; //ʹÖÁ±ä³É»ÒÉ«
(RdGrpComName.Controls[j] as TRadioButton).Checked := False; //ͬʱʹÆä²»±»Ñ¡Ôñ£¡
end;
end;
end;
finally
st.Free;
end;
reg.CloseKey;
finally
reg.Free;
end;
procedure TFrmMain.FormCreate(Sender: TObject);
var
reg:TRegistry; //ÉùÃ÷Ò»¸öTRegistryÀà±äÁ¿
st: Tstrings;
i: Integer;
j: Integer;
pcpt: string;
begin
reg := TRegistry.Create;
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
pcpt:=Trim(reg.Readstring(st.strings));
// RadioGroup disable
for j := 0 to 7 do
begin
if RdGrpComName.Items[j] = pcpt then
Self.RdGrpComName.Controls[j].Enabled := true
else
begin
Self.RdGrpComName.Controls[j].Enabled := false; //ʹÖÁ±ä³É»ÒÉ«
(RdGrpComName.Controls[j] as TRadioButton).Checked := False; //ͬʱʹÆä²»±»Ñ¡Ôñ£¡
end;
end;
end;
finally
st.Free;
end;
reg.CloseKey;
finally
reg.Free;
end;