[fpc-pascal]reading windows registry

Michael Van Canneyt michael.vancanneyt at wisa.be
Tue Feb 3 10:42:28 CET 2004


On Mon, 2 Feb 2004, Charl van Jaarsveldt wrote:

> Hallo.
>
> I have this little program to get te info of a certain ODBC entry n the
> registry, but it doesn't work and I am at a loss. I admit, I haven't
> done too much win32 stuff before. Any ideas and help would be appreciated.

I suggest using the TRegistry class in the registry unit. Your code
would be reduced to:

S:=Paramstr(1);
With TRegistry.Create do
  try
    RootKey:=HKEY_LOCAL_MACHINE;
    If OpenKeyReadOnly('Software\ODBC\ODBC.INI\ODBC Data Sources') then
      If ValueExists(S) then
        S:=ReadString(S); // Or whatever it is. ReadInteger/ReadBool
  finally
    Free;
  end;

Michael.




More information about the fpc-pascal mailing list