Search code examples
delphipostgresqlpgadmin

Programmatical register a Postgres Server with pgAdmin using Delphi


Im working on an application using Postgres 9 and Delphi 7 as the front end, For setting up the database connection to the application we have to do the following steps

1.Register a server in postgres (i cannot post an image because im new user)

   Name:=Localhost
   Host:=Localhost
   Port:=5432
   SSL:=
   MaintenanceDB:=myDB
   Username:=Admin
   password:=******
   .
   .
   Service:=Localhost

2.Create the database and the tables.

Can any one tell me if the step 1. can be done programatically? Like for example "C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h localhost -p 5432 -d myDB -U Admin Service=Localhost " ?

as of now its done manually by the user.

thanks in advance:)


Solution

  • The registered servers in pgAdmin are stored in the Windows registry under HKEY_CURRENT_USER\Software\pgAdmin III\Servers

    The number of registered servers is stored in the Count attribute.

    Then each server gets its own entry according to the number. So the first one is stored in HKEY_CURRENT_USER\Software\pgAdmin III\Servers\1, the second one in HKEY_CURRENT_USER\Software\pgAdmin III\Servers\2 and so on.

    Have a look into your registry and create an approriate entry from within your Delphi application.