由于我要运行WINDOW里面的一些自带的程序,所以我必须得知WINDOW的安装目录,请问如何实现?谢谢

解决方案 »

  1.   

    用GetSystemDirectory  api函数
    UINT GetSystemDirectory(
      LPTSTR lpBuffer,  // address of buffer for system directory
      UINT uSize        // size of directory buffer
    );
      

  2.   

    1)
       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: " + sSave2)
    Private Declare Function GetWindowsDirectory lib "kernel32" Alias "GetWindowsDirectoryA" ( ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Dim Temp As String * 256
    dim WinDir as string
    X = GetWindowsDirectory(Temp, Len(Temp))
    WinDir = Left$(Temp, X)
    msgbox windir