🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.program
Article #2088

Edit Register Sample

#2088
From: �����п�
Date: Sun, 01 Feb 1998 00:00
119 lines
4679 bytes
// ������c++ builder�༭ע��������
//***********************************************
// Written by Mr. Michael Jia   1998-01-31
//***********************************************
#include <vcl\vcl.h>
#include <vcl\registry.hpp>
#pragma hdrstop
#include "testr.h"
//--------------------------------------------------------------------------
-
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString path,font,color;
//--------------------------------------------------------------------------
-
__fastcall TForm1::TForm1(TComponent* Owner)
 : TForm(Owner)
{
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::exitClick(TObject *Sender)
{
Close();
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::saveClick(TObject *Sender)
{  TRegistry *regtable ;
    regtable=new (TRegistry);
    /*************************************************************
     1.Install Soft  must be put here:
       HKEY_LOCAL_MACHINE\Software\yourCompany\yourrProduct\ver1.0
     2.If your software support ole must be put here:
       HKEY_LOCAL_MACHINE\Software\Classes
     3.Data you use must be put here:
       HKEY_CURRENT_USER\Software\MyCompany\MyProduct\1.0\...
     <<my sample is
        HKEY_CURRENT_USER\Software\MichaelJia
           Path
           Font
           Color
     >>
      Notice: CreateKey(OpenKey) & CloseKey must be pair.
    **************************************************************/
    if (regtable->OpenKey("Software",false)==true)  //change RootKey
    {regtable->RootKey=regtable->CurrentKey;
     //Now RootKey is HKEY_LOCAL_MACHINE\Software
     regtable->CloseKey();
    }
    else {MessageBox(0,"Change RootKey Error!!!","message",MB_OK);
          return ;
         }
  if(regtable->OpenKey( "MichaelJia",false)==true)  //save
     {regtable->WriteString("Path",path->Text);
      regtable->WriteString("Font",font->Text);
      regtable->WriteString("Color",color->Text);
      regtable->CloseKey();
     }
  else{
       if( regtable->CreateKey("MichaelJia")==true)
          {//if the first time just create the KEY
          regtable->CloseKey();   //after you create it ,you must close it
                                  //for reopenning to write    !!!!!
          MessageBox(0,"First time ,MichaelJia created!","message",MB_OK);
           //set default values
          regtable->OpenKey("MichaelJia",false);
          regtable->WriteString("Path","Hello,World");
          regtable->WriteString("Font","C++ Builder");
          regtable->WriteString("Color","My name is Michael Jia");
          regtable->CloseKey();
          }
        else
          {MessageBox(0,"Write error,other program locks the
Registry","message",MB_OK);
          }
     };
 // regtable->CloseKey();   //close registry table
}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::loadClick(TObject *Sender)
{
 TRegistry *regtable ;
    regtable=new (TRegistry);
    if (regtable->OpenKey("Software",false)==true)  //change RootKey
    {regtable->RootKey=regtable->CurrentKey;
     //Now RootKey is HKEY_LOCAL_MACHINE\Software
      regtable->CloseKey();
    }
    else {MessageBox(0,"Change RootKey Error!!!","message",MB_OK);
          return ;
         }
  if(regtable->OpenKey( "MichaelJia",false)==true)  //save
     {
      path->Text=regtable->ReadString("Path");
      font->Text=regtable->ReadString("Font");
      color->Text=regtable->ReadString("Color");
      regtable->CloseKey();
     }
  else {
 MessageBox(0,"Read error!!! \nMaybe other program locks the Registry or you
don't save it first!","message",MB_OK);
           };
  //regtable->CloseKey();   //close registry table

}
//--------------------------------------------------------------------------
-
void __fastcall TForm1::changeClick(TObject *Sender)
{ AnsiString saves;
saves=path->Text;
path->Text=font->Text;
font->Text=color->Text;
color->Text=saves;
}
//--------------------------------------------------------------------------
-
Technical Details
Message-ID: <6ausel$8ar$1@clinux.ml.org>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: fc86e,43f5f8542a910892,start
X-Google-Attributes: gidfc86e,public
From: "�����п�" <jia@gicom2000.com>
Subject: Edit Register Sample
Date: 1998/02/01
Message-ID: <6ausel$8ar$1@clinux.ml.org>
X-Deja-AN: 320807027
X-Server-Date: 31 Jan 1998 09:55:33 GMT
X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3
Organization: Chinese Linux User Group
Newsgroups: cn.bbs.comp.program