Excel tip: Get the windows directoryDate: 5 september 2001The following function will give you the directory where MS Windows is installed. This code is very usefull because the directory is not always "c:\windows", i.e. for Windows 2000 this is "c:\winnt". Copy-paste friendly code: Option Explicit
'Windows API/Global Declarations Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _ (ByVal lpBuffer As String, _ ByVal nSize As Long) As Long Function fGetWinDir() As String Dim lRet As Long Dim lSize As Long Dim sBuf As String * 260 '260 = max path lSize = 260 lRet = GetWindowsDirectory(ByVal sBuf, ByVal lSize) If InStr(1, sBuf, Chr(0)) > 0 Then fGetWinDir = Left(sBuf, InStr(1, sBuf, Chr(0)) - 1) Else fGetWinDir = "" End If End Function Sub TestDisplayWinDir() MsgBox "Your windows directory is:" & vbNewLine & _ fGetWinDir(), vbInformation, "Windows folder" End Sub « back | ||
Home
Privacy Policy
Cookie Policy
EULA
Sitemap
Search
List of all utilities
Printer friendly page
Contact Us
^ Back to Top
© 1999-2021 - Bastien Mensink - ASAP Utilities - A Must in Every Office BV - The Netherlands
Connect with us and receive our tips that show you how to benefit from the tools in ASAP Utilities at:
![]() ![]() |