Saludos a todos.
Hace unos días solicité ayuda con respecto a la lectura y escritura del registro Windows. Luego de leer sobre TRegistry, hice las rutinas correpondiente y la declaración de las variables y uses necesarios. El compilador me arroja un error diciéndome que la variable RegNGFS no está declarada. ¿Podría alguien indicarme que es lo que está mal en el código?
Por cierto, ¿está bien hecha la declaración den enteros sin signo, Cardinal?
Muchas Gracias.
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
end;
var
Form1: TForm1;
MaxSteps: Cardinal; MinSteps: Cardinal; StopOUT: Cardinal; StopIN: Cardinal; COMPort: String;
implementation
{$R *.dfm}
procedure ReadRegistry( MaxSteps: Cardinal; MinSteps: Cardinal;
StopOUT: Cardinal; StopIN: Cardinal; COMPort: String);
begin
try
RegNGFS:= TRegistry.Create;
RegNGFS.RootKey := HKEY_LOCAL_MACHINE;
if RegNGFS.OpenKey('SOFTWARE\NGFS', FALSE) then begin
MaxSteps:= RegNGFS.ReadCardinal('MaxSteps');
MinSteps:= RegNGFS.ReadCardinal('MinSteps');
StopOUT:= RegNGFS.ReadCardinal('StopOUT');
StopIN:= RegNGFS.ReadCardinal('StopIN');
COMPort:= RegNGFS.ReadString('COMPort');
end;
finally
RegNGFS.Free;
end;
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;
end.