office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

使用API獲取windows系統路徑(System32)目錄的函數

2017-07-22 22:41:00
zstmtony
原創
1140

Access VBA 使用API獲取windows系統路徑(System32)目錄的函數

(如果是windows  64位系統,則獲取的是 64位的系統目錄)


OptionExplicit
PublicConst MAX_PATH = 260
'作者:tmtony-Office交流網
DeclareFunction GetSystemDirectory Lib "kernel32" Alias"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long)As Long
Public Function MyGetSystemDirectory() as String
    Dim S As String, Length As Long
    S = String(MAX_PATH, 0)
    Length = GetSystemDirectory(S, MAX_PATH)
    S = Left(S, InStr(S, Chr(0)) - 1)
    MyGetSystemDirectory=S  'Windows System 系統路徑 
End Sub

Sub Main()
    Msgbox MyGetSystemDirectory()
End Sub

如果是windows 64位,想獲取 32位的系統目錄呢。則可以參考這里

http://www.guizmj.live/access-function/142.html

分享
北京十一选五基本走势