Für 32Bit und 64Bit Office Versionen
Problemstellung:
Wie ermittle ich das Windowssystem-Verzeichnis?
#If VBA7 Then 'Code für 32 bit und 64 bit Office VBA 7 #If Win64 Then 'Code für 64-bit Office VBA 7 Declare PtrSafe Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long #Else 'Code für 32-bit Office VBA 7 Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long #End If #Else 'Code für VBA 6 (32 bit) Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long #End If Function GetSystemDir() As String '******************************************* 'Name: GetSystemDir (Function) 'Purpose: ermittelt das aktuelle Systemverzeichnis 'Author: Thomas Keßler 'Date: Januar 28, 2003, 05:03:42 'Inputs: 'Output: '******************************************* Dim Ret As Long Dim strBuffer As String, lLength As Long strBuffer = String$(255, 0) lLength = Len(strBuffer) Ret = GetSystemDirectory(strBuffer, lLength) If Ret <> 0 Then GetSystemDir = Left$(strBuffer, Ret) End Function
Aufruf:
Dim x As String x = GetSystemDir()
Das Ergebniswäre x = "C:\WINDOWS\System32"
Ähnliche Artikel
Weiterlesen...