Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I insert registry keys on Borland C++ Builder? 2

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I insert registry keys to windows OS's Registry on Borland C++ Builder? what is the source code for this?

thanks in advance.

 
There is a special class TRegistry for such purposes. With the methods of this class you can read, write, delete etc. Registry keys.

hnd
hasso55@yahoo.com

 
You could use the Online-Help or today in the evening i will post an example.

hnd
hasso55@yahoo.com

 
Following an abbreviated Example for the Use of TRegistry
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
.
.
.

#include <Registry.hpp>
.
.
.
void __fastcall TForm1::Setup(TObject *Sender)
{
.
.
.
TRegistry *dbconfig;
.
.
.
dbconfig=new TRegistry();
dbconfig->CloseKey();
dbconfig->RootKey=HKEY_LOCAL_MACHINE;
// Check if Key &quot;First Time&quot; exists

if(dbconfig->KeyExists(&quot;SOFTWARE\\CBS\\FIRST_TIME&quot;))
{
// if yes Open the Path Data
// 1. Configuration Data Path
if(dbconfig->OpenKey(&quot;Software\\CBS\\Path&quot;,false))
{
keystring=dbconfig->ReadString(&quot;Config&quot;);
strcpy(parameter->cnfgpath,keystring.c_str());
for (cnt=0;cnt<strlen( parameter->cnfgpath );cnt++)
{
if(parameter->cnfgpath[cnt]=='\\')
parameter->cnfgpath[cnt]='/';
}
// 2. Program Path
keystring=dbconfig->ReadString(&quot;Prog&quot;);
strcpy(parameter->progpath,keystring.c_str());
for (cnt=0;cnt<strlen( parameter->progpath );cnt++)
{
if(parameter->progpath[cnt]=='\\')
parameter->progpath[cnt]='/';
}
// 3. Data Path
keystring=dbconfig->ReadString(&quot;Data&quot;);
strcpy(parameter->datapath,keystring.c_str());
for (cnt=0;cnt<strlen( parameter->datapath );cnt++)
{
if(parameter->datapath[cnt]=='\\')
parameter->datapath[cnt]='/';
}
}
else
{
// If Key on Path data does not exist => Errormessage
Application->MessageBox(parameter->Tofl[147],parameter->Tofl[91],MB_OK|MB_ICONHAND);
}
}
dbconfig->CloseKey();
dbconfig->RootKey=HKEY_CURRENT_USER;
if(dbconfig->KeyExists(&quot;\\Software\\CBS\\LANGUAGE&quot;))
{
if(dbconfig->OpenKey(&quot;\\Software\\CBS\\LANGUAGE&quot;,false))
{
parameter->language=dbconfig->ReadInteger(&quot;Langdef&quot;);
}
}
else
parameter->language=0;

dbconfig->CloseKey();


delete(dbconfig);
//==========================================================


hnd
hasso55@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top