获取系统目录和Windows目录

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

有时我们需要让自己的程序判断系统目录和Windows目录的名字。这时可以调用WindowsAPI函数GetSystemDirectory和GetWindowsDirectory。

声明:

' 获取系统目录
Public Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
    (ByVal lpBuffer As String, ByVal nSize As Long) As Long

' 获取Windows目录
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" _
    (ByVal lpBuffer As String, ByVal nSize As Long) As Long

调用:

' 检查系统目录
Public Function GetSystemPath() As String
    Dim p As String * 80
    Dim length As Long
    Dim path As String
   
    length = GetSystemDirectory(p, Len(p))
    path = Left(p, length)
   
    GetSystemPath = path
End Function


' 检查Windows目录
Public Function GetWindowsPath() As String
    Dim p As String * 80
    Dim length As Long
    Dim path As String
   
    length = GetWindowsDirectory(p, Len(p))
    path = Left(p, length)
   
    GetWindowsPath = path
End Function

本文关键:获取系统目录和Windows目录
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top