取得Window, System, Temp所在目录 
 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 LongPrivate 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 
   
 
  
 

解决方案 »

  1.   

    计算器在windows 目录中取得windows目录象下面这样的调用就行Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Form_Load()
    Call ShellExecute(Form1.hwnd, "Open", "c:\windows\calc.exe", "", App.Path, 1)End Sub