Solved

sql directory

Posted on 2002-03-12
9
149 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

777 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