Solved

Get windows system directory

Posted on 2004-05-03
3
424 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
  • 2
3 Comments
 
LVL 53

Expert Comment

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

Accepted Solution

by:
Dhaest earned 125 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

765 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