unit com;
interface
uses Messages,classes,sysutils,Windows,mmsystem;
var
COMM:string;
BaudRate:string;
procedure ReadRegValue;
procedure WriteRegValue;
implementation
uses registry;
procedure ReadRegValue;
var Reg:TReginiFile;
begin
reg:=TRegIniFile.Create('PCSYN');
Reg.RootKey:=HKEY_LOCAL_MACHINE;
try
if Reg.OpenKey('\SOFTWARE\MobileInnovation',True) then
begin
COMM:='COM'+reg.ReadString('PCSYN','COM','1');
BaudRate:=reg.ReadString('PCSYN','BaudRate','115200');
end else
Raise Exception.Create('软件未正确安装!');
finally
Reg.Free;
end;
end;
procedure WriteRegValue;
var Reg:TReginiFile;
tempcom:string;
begin
reg:=TRegIniFile.Create('PCSYN');
Reg.RootKey:=HKey_Local_Machine;
try
if Reg.OpenKey('\SOFTWARE\MobileInnovation',True) then
begin
tempcom:=COMM;
delete(tempcom,1,3);
reg.WriteString('PCSYN','COM',tempcom);
reg.WriteString('PCSYN','BaudRate',BaudRate);
end else
Raise Exception.Create('软件未正确安装!');
finally
Reg.Free;
end;
end;
initialization
ReadRegValue;
WriteRegValue;
finalization
WriteRegValue;
end.