Ver Mensaje Individual
  #2  
Antiguo 15-06-2004
Avatar de delphi.com.ar
delphi.com.ar delphi.com.ar is offline
Federico Firenze
 
Registrado: may 2003
Ubicación: Buenos Aires, Argentina *
Posts: 5.932
Reputación: 27
delphi.com.ar Va por buen camino
De antemano te comento que no conozco C++ en profundidad, pero esto lo hice funcionar:
Código:
//---------------------------------------------------------------------------
#include <vcl.h>
#include <registry.hpp>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    const String Regkey = "\\software\\Mi Marca\\Mi Soft\\";

    TRegistry *MyRegistry = new TRegistry();
    try {
      MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
   	  MyRegistry->OpenKey(Regkey, True);
      Button1->Enabled = MyRegistry->ReadBool(Button1->Name);
   	}
   	catch(ERegistryException &E) {
 	  ShowMessage(E.Message);
      delete MyRegistry;
      return;
    }
   	delete MyRegistry;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
    const String Regkey = "\\software\\Mi Marca\\Mi Soft\\";

    TRegistry *MyRegistry = new TRegistry();
    try {
      MyRegistry->RootKey = HKEY_LOCAL_MACHINE;
   	  MyRegistry->OpenKey(Regkey, True);
      MyRegistry->WriteBool(Button1->Name, Button1->Enabled);
   	}
   	catch(ERegistryException &E) {
 	  ShowMessage(E.Message);
      delete MyRegistry;
      return;
    }
   	delete MyRegistry;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  Button1->Enabled = !Button1->Enabled;
}
//---------------------------------------------------------------------------
__________________
delphi.com.ar

Dedique el tiempo suficiente para formular su pregunta si pretende que alguien dedique su tiempo en contestarla.
Responder Con Cita