新聞| | PChome| 登入
2007-10-25 22:51:33 | 人氣119| 回應0 | 上一篇 | 下一篇
推薦 0 收藏 0 轉貼0 訂閱站台

取得Window, System, Temp所在目錄

來源:cww

Private Declare Function GetWindowsDirectory Lib "kernel32" Alias _
        "GetWindowsDirectoryA" (ByVal lpBuffer As String, _
        ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
        "GetSystemDirectoryA" (ByVal lpBuffer As String, _
        ByVal nSize As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" _
        (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Private Sub Command1_Click()
Dim WinPath As String, SysPath As String
Dim tempPath As String
Dim len5 As Long
'取得Windows 的目錄
WinPath = String(255, 0)
len5 = GetWindowsDirectory(WinPath, 256)
WinPath = Left(WinPath, InStr(1, WinPath, Chr(0)) - 1)
Debug.Print "Window Path = "; WinPath

'取得Windows System的目錄
SysPath = String(255, 0)
len5 = GetSystemDirectory(SysPath, 256)
SysPath = Left(SysPath, InStr(1, SysPath, Chr(0)) - 1)
Debug.Print "System Path : "; SysPath

'取得Temp的Directory
tempPath = String(255, 0)
len5 = GetTempPath(256, tempPath)
tempPath = Left(tempPath, len5)
Debug.Print "TEMP Path :"; tempPath
End Sub

台長: Kenny
人氣(119) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 教育學習(進修、留學、學術研究、教育概況) | 個人分類: 程式設計 |
此分類下一篇:含子目錄的搜尋檔案
此分類上一篇:字串中文的問題

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文