Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Windows install directory

Status
Not open for further replies.

dstepans

Programmer
Jun 3, 2003
39
0
0
US
Hello,

how could I get a path to the directory where windows is installed. I am using vb6.

TIA,
Denis
 
dstepans,

Would it work for you?

MyWindowsDirectory = Environ$("WINDIR")

Vladk
 
Thanks guys.
I'll try it. Ran into some urgent problems that have to be resolved first.

Denis
 
Before using the environ solution do a keyword search to see why it may give you problems, it has been talked to death.
 
Here's another option:

Public Declare Function GetWindowsDirectory Lib _
"kernel32" Alias "GetWindowsDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) _
As Long

Public Function GetWin() As String
Dim P As Long
Dim tmpString As String
tmpString = String$(255, Chr(13))
P = GetWindowsDirectory(tmpString, 255)
GetWin = Mid$(tmpString, 1, InStr(1, tmpString, _
Chr(13), vbTextCompare) - 2)
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top