Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Reading/Writing to Windows Registry

Author  Topic 

rajk
Starting Member

20 Posts

Posted - 2003-08-27 : 08:09:16
Hi,

I have a situation where I need to store a password (for an application role) into the registry and an application would read the password from the registry and use it.

Help in writing to registry (one time job..can happen through windows GUI..manually) and reading (needs to happen by a sql server SP or by a Visual Basic utility every time the appliction is launched) would be greatly appreciated.

Thanks
Raj

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2003-08-27 : 08:26:16
What about using xp_regread to read? Something like

DECLARE @dpath varchar(255)
DECLARE @lpath varchar(255)
EXEC master..xp_regread
'HKEY_LOCAL_MACHINE',
'Software\Microsoft\MSSQLServer\MSSQLServer',
'DefaultData',
@dpath OUTPUT

EXEC master..xp_regread
'HKEY_LOCAL_MACHINE',
'Software\Microsoft\MSSQLServer\MSSQLServer',
'DefaultLog',
@lpath OUTPUT

PRINT @dpath
PRINT @lpath


For writing you can use xp_regwrite like

EXECUTE master.dbo.xp_regwrite
'HKEY_LOCAL_MACHINE',
'Software',
'MyTest',
'REG_SZ',
'Hello World'



From VB you can utilize advapi32.dll. Examples on the use of this can you find in MSDN


Cheers,
Frank
Go to Top of Page
   

- Advertisement -