You are here:

Visual Basic/determining %systemroot%

Advertisement


Question
I am writing a program in VB6 where I need to determine the path for the %systemroot%\system32\ folder, and set the value of a string variable to equal this value.

What is the easiest way to do this?


Answer
Hi Kevin,

try this -

Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long

Private Sub Form_Load()
Dim strPath As String, lngRes As Long
strPath = Space(255)
lngRes = GetSystemDirectory(strPath, 255)
sSave = Left$(strPath, lngRes)
MsgBox strPath
End Sub

OR

MsgBox Environ$("systemroot")

HTH.

Visual Basic

All Answers


Answers by Expert:


Ask Experts

Volunteer


Kaustav Neogy

Expertise

i can try answer to queries related to general VB/VB.NET programming, ADO/ADO.NET, handling databases etc.

Experience

I have been working with VB and VB.NET for over 3 years.

©2012 About.com, a part of The New York Times Company. All rights reserved.