Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Use registry instead of *.ini file
Ini files are necessary for a storage of an information and parameters of the programs. It is possible to do it with use a registry.
This example create HKEY_LOCAL_MACHINE\Greatis Software\Example key with "First page" parameter, which stores a path to rtf file. This file will be loading from this parameter after Button2 click event.
You can store boolean, time and others types of variables in registry also.

uses Registry;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
  with TRegistry.Create do
  begin
   LazyWrite:=False;
   RootKey:=HKEY_LOCAL_MACHINE;
   if OpenKey('Greatis Software\Example', True) then
     WriteString('First page', 'c:\overview.rtf')
   else
     MessageDlg('Registry reading error', mtError, [mbOk], 0);
   CloseKey;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  with TRegistry.Create do
  begin
    RootKey:=HKEY_LOCAL_MACHINE;
    if OpenKey('Greatis Software\Example', False) then
    try
      RichEdit1.Lines.LoadFromFile(ReadString('First page'));
    except
      MessageDlg('Can not go to handle', mtError, [mbOk], 0);
    end
    else
      MessageDlg('Registry reading error', mtError, [mbOk], 0);
    CloseKey;
  end;
end;

Related chapters
System

Related topics
Detect windows version
Detect font (Small or Large) is in use
Run program not in StartUp Folder

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software