Ok Dec, aquí va todo el código. No hay nada más. Esta es la forma:
Código Delphi
[-]
unit NGFS;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, CPortCtl, CPort, Registry;
type
TForm1 = class(TForm)
BIn: TButton;
BOut: TButton;
GroupBox1: TGroupBox;
LCurrPos: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
BGoto: TButton;
LTotStep: TLabel;
BCali: TButton;
PBCurrPos: TProgressBar;
Timer1: TTimer;
ComComboBox1: TComComboBox;
ComPort1: TComPort;
ComLed1: TComLed;
Eminstep: TEdit;
Emaxstep: TEdit;
Label1: TLabel;
Eminstop: TEdit;
Label7: TLabel;
Emaxstop: TEdit;
BConnect: TButton;
EGoto: TEdit;
private
RegNGFS: TRegistry;
public
procedure ReadRegistry(MaxSteps: Integer; MinSteps: Integer;
StopOUT: Integer; StopIN: Integer; COMPort: String);
procedure WriteRegistry( );
end;
var
Form1: TForm1;
MaxSteps: Cardinal; MinSteps: Cardinal; StopOUT: Cardinal; StopIN: Cardinal; COMPort: String;
implementation
{$R *.dfm}
procedure ReadRegistry(MaxSteps: Integer; MinSteps: Integer;
StopOUT: Integer; StopIN: Integer; COMPort: String);
begin
try
RegNGFS:= TRegistry.Create;
RegNGFS.RootKey := HKEY_LOCAL_MACHINE;
if RegNGFS.OpenKey('SOFTWARE\NGFS', FALSE) then begin
RegNGFS.ReadCardinal('MaxSteps');
MinSteps:= RegNGFS.ReadCardinal('MinSteps');
StopOUT:= RegNGFS.ReadCardinal('StopOUT');
StopIN:= RegNGFS.ReadCardinal('StopIN');
COMPort:= RegNGFS.ReadString('COMPort');
end;
finally
RegNGFS.Free;
end;
procedure WriteRegistry( );
begin
try
RegNGFS:= TRegistry.Create;
RegNGFS.RootKey := HKEY_LOCAL_MACHINE;
if RegNGFS.OpenKey('SOFTWARE\NGFS', TRUE) then begin
RegNGFS.WriteCardinal('MaxSteps', MaxSteps);
RegNGFS.WriteCardinal('MinSteps', MinSteps);
RegNGFS.WriteCardinal('StopOUT', StopOUT);
RegNGFS.WriteCardinal('StopIN', StopIN);
RegNGFS.WriteString('COMPort', COMPort);
end;
finally
RegNGFS.Free;
end;
end.