Solved

sql directory

Posted on 2002-03-12
9
148 Views
Last Modified: 2012-05-04
how do i get the sql directory..?
(e.g. c:\mssql)
0
Comment
Question by:killer5
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now