Ver Mensaje Individual
  #11  
Antiguo 11-10-2005
CelestronFan CelestronFan is offline
Miembro
 
Registrado: oct 2005
Posts: 14
Reputación: 0
CelestronFan Va por buen camino
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
     { Private declarations }
    RegNGFS: TRegistry;
   public
     { Public declarations }
      procedure ReadRegistry(MaxSteps: Integer; MinSteps: Integer;
                       StopOUT: Integer; StopIN: Integer; COMPort: String);
     procedure WriteRegistry( );
 
   end;
 
 var
   Form1: TForm1;
   MaxSteps: Cardinal;   //Número máximo de pasos del Stepper
   MinSteps: Cardinal;   //Número mínimo de pasos del Stepper
   StopOUT: Cardinal;    //Posición de parada sentido OUT del Stepper
   StopIN: Cardinal;     //Posición de parada sentido IN del Stepper
   COMPort: String;      //Puerto Serial seleccionado
 
 implementation
 
 {$R *.dfm}
 
 procedure ReadRegistry(MaxSteps: Integer; MinSteps: Integer;
                        StopOUT: Integer; StopIN: Integer; COMPort: String);
 
 //Procedimiento para leer el registro//
 
 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( );
 
 //Procedimiento para escribir el registro//
 
 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.
Responder Con Cita