Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'E-Mail: [email protected]
    Dim sSave As String, Ret As Long
    'Create a buffer
    sSave = Space(255)
    'Get the system directory
    Ret = GetSystemDirectory(sSave, 255)
    'Remove all unnecessary chr$(0)'s
    sSave = Left$(sSave, Ret)
    'Show the windows directory
    MsgBox "Windows System directory: " + sSave
End Sub

解决方案 »

  1.   

    读取注册表,HKEY_LOCALMACHINE\software\microsoft\windows\currentversion\setup\windir即可.
      

  2.   

    简单明了直接:
    str=app.path & "\member.mdb"
    msgbox str
    看看什么效果你就知道了
      

  3.   

    dim ap as string
    if right$(trim(app.path),1)<>"\" then
      ap=trim(app.path)+"\"
    end if
    ap=ap+"\mdb"我想这样更安全些!
      

  4.   

    Dim PathLen As Long,WinDir as String,ProgramPath as String,pPathName as String'获取程序所在目录
    ProgramPath = App.Path
    If Right(ProgramPath, 1) <> "\" Then
    ProgramPath = ProgramPath + "\"
    End If'获取程序的完整名称
    pPathName = ProgramPath + App.EXEName + ".exe"'获取Windows所在目录
    WinDir = Space(MAX_PATH)
    PathLen = GetWindowsDirectory(WinDir, MAX_PATH)
    If PathLen > MAX_PATH Then
    PathLen = GetWindowsDirectory(WinDir, PathLen)
    End If
    WinDir = Left(WinDir, PathLen)
    If Right(WinDir, 1) <> "\" Then
    WinDir = WinDir + "\"
    End IfGetWindowsDirectory的声明及用到的常数,请从API浏览器中复制。