Solved

sql directory

Posted on 2002-03-12
9
152 Views
Last Modified: 2012-05-04
how do i get the sql directory..?
(e.g. c:\mssql)
0
Comment
Question by:killer5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6859763
Hi killer5, you could try the registry under the following key

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup

The actual executables will be in "Binn" under the directory specified at this key.

HTH:O)Bruintje
0
 
LVL 1

Author Comment

by:killer5
ID: 6859769
how do i get the SQL directory thru VB?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6859823
As bruintje said, read the registry.
you'll need some declarations like:
Option Explicit

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.

Then you'll need a function to open, read and close the registry. For the reading part, something like:
        lngResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup)

Play around with these api calls. Very helpful.

Bye

Rem
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 44

Accepted Solution

by:
bruintje earned 5 total points
ID: 6859832
and of course you could take a look at essentially the same sort of code including a complete get key function at

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=10479&lngWId=1

:O)Bruintje
0
 
LVL 3

Expert Comment

by:Rem
ID: 6859846
Jeez Bruintje, I just woke up, don't ask too much. LOL

I just stripped a bit from my own old stuff looking up the ODBC.INI and changed the string to the one you mentionned.
0
 
LVL 1

Author Comment

by:killer5
ID: 6859908
i don't wanna play around... i'ma  lazy person

can someone give me a function that will search for the SQLPath value in the registry?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6859923
The link bruintje provided gives you what you asked for.
This site is to help people having a specific problem. If you want other people to do your work, or do complete projects, my guess is that you're not on the right website.
Experts gave you what you asked for. So please read the EE guidelines.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6861237
Grade changed.

killer5,

Laziness on your part is no excuse for not rewarding Experts for their assistance, especially when you add questions to the original question without adding points.

Netminder
Community Support Moderator
Experts Exchange
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6861255
;) thanks netminder
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question