Avatar of ISIGest
ISIGestFlag for Italy asked on

Current Listening SQL Server 2008 TCP/IP Port Delphi

How i can set the TCP/IP listening port for SQL Server Express 2008 programmatelly??
Editors IDEsDelphiMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
Geert G

8/22/2022 - Mon
ASKER
ISIGest

I run a Vista Businnes 64bit and i've been installed a SQL Server 2008 64bit version and a SQL Server 2005 32bit.
When i try access to a registry key value:
SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL
the result of existing key value is only SQL2005 becouse it access to:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\Instance Names\SQL
How i can access to a 64bit (Standard) key values?
const
  INSTANCE_KEY = 'SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL';
  KEY_VALUES = 'SOFTWARE\Microsoft\Microsoft SQL Server\%s\MSSQLServer\SuperSocketNetLib\Tcp\IPAll';
var
  LValue: string;
  LReg: TRegistry;
begin
 
  LReg := TRegistry.Create;
  try
    with LReg do begin
      RootKey := HKEY_LOCAL_MACHINE;
      if OpenKeyReadOnly(INSTANCE_KEY) then begin
        if ValueExists(SQLSERVEREXPRESS_ISTANZA_DEFAULT) then
          LValue := ReadString(SQLSERVEREXPRESS_ISTANZA_DEFAULT);
 
        CloseKey;
 
        if not Empty(LValue) then begin
          if OpenKey(Format(KEY_VALUES, [LValue]), False) then begin
            WriteString('TcpDynamicPorts', EmptyStr);
            WriteString('TcpPort', IntToStr(SQLSERVEREXPRESS_PORTA_DEFAULT));
            CloseKey;
          end;
        end
        else begin
          // ERROR
 
        end;
      end;
    end;
  finally
    LReg.Free;
  end;
end;

Open in new window

Geert G

ASKER CERTIFIED SOLUTION
Geert G

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes