AllExperts > Visual Basic 
Search      
Visual Basic
Volunteer
Answers to thousands of questions
 Home · More Visual Basic Questions · Answer Library  · Encyclopedia ·
More Visual Basic Answers
Question Library

Ask a question about Visual Basic
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About 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.

 
   

You are here:  Experts > Computing/Technology > Basic > Visual Basic > determining %systemroot%

Visual Basic - determining %systemroot%


Expert: Kaustav Neogy - 8/2/2006

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.

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.