?
Solved

Get windows system directory

Posted on 2004-05-03
3
Medium Priority
?
427 Views
Last Modified: 2012-08-14
How can I retrieve the Windows root directory or the system32 directory?
I've been looking for an API GetSystemRoot or GetWindowsRoot or something like that with no result...
0
Comment
Question by:boeman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 10975450
Try:
environ("windir")
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 10975457
Or

Option Explicit
Private Declare Function GetSystemDirectory Lib "KERNEL32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Private Sub Command1_Click()
    Dim strBuf As String

    strBuf = Space$(255)
    GetSystemDirectory strBuf, 255
    strBuf = Left$(strBuf, InStr(strBuf, Chr$(0)) - 1)
    Debug.Print strBuf
End Sub
0
 
LVL 3

Author Comment

by:boeman
ID: 10975535
muchos gracias
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 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