• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Win32Exception: Failed to open 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_5

 
Mukund Patil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi am getting the

Win32Exception: Failed to open 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\Parameters', error 2.: 2

issue to get the path of MS SQL Server using code -

if (RegistryKey.keyExists("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL10_50.MSSQLSERVER\\MSSQLServer\\Parameters"))

the same code works on XP 32 bit machine but not working on any 64 bit window 7 or win 2003 server machine.


could you some one help me please?

Thanks,
Mukund
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By far the best solution would be to make do without reading the registry. Why do you need to get the path where MS SQL Server is installed?

Anyway: you've probably run into the remapping of directories and registry keys which some exceptionally bright mind introduced into 64-bit versions of Windows. When a 32-bit application running on 64-bit Windows tries to access certain files or registry keys, the operating system silently redirects the request into other directories/registry keys. The net result is that 32bit and 64bit application sees different files/registry values when using the same name. (See how useful is that? I don't.)

While a 32-bit application can probably circumvent these redirections somehow, I'd suggest to simply run your application using 64-bit version of the JVM. This way your application won't be subject to these redirections. If this solution is not acceptable to you, you'll need to google up something like WOW64 redirections. I'm really no expert on this and I'm battling this insanity myself from time to time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic