我发现调用的GetWindowsDirectory()获取windows目录的这个api函数和所使用操作系统的环境有关。
有时候会返回c:\WINNT(Windows 2000)或c:\Windows(Windows 2003)系统目录
有时候会返回当前登录用户,也就是c:\documents and setting\$登录用户名\windows\目录路径,
具体什么情况返回什么值,这个目前尚未定位。
请大侠们指教,100分小意思,不成敬意。多谢!

解决方案 »

  1.   

    这个应该是和环境变量 %PATH%有关,它的取值就是 %PATH%得值。
      

  2.   

    MSDN 里有变文章可以做正解了Finding the System Directory on Terminal ServerThe GetWindowsDirectory function retrieves the path of the Windows directory, and returns a per-user system directory. If you're running on terminal server, you may find that you're not getting the real system directory; you may be getting a system directory that's set up for a particular user. Use the GetWindowsSystemDirectory function to get the actual system directory on terminal server.GetWindowsDirectory 跟用户有关系推荐用GetSystemWindowsDirectory
      

  3.   

    那什么类型的用户返回per-user   system   directory呢?请指教。多谢!
      

  4.   

    Terminal   Server 
      

  5.   

    如果是想获取Windows系统的目录,强烈建议你用GetSystemWindowsDirectory这个函数
      

  6.   

    谢谢各位大侠的解答,到现在我还是不清楚。
    我只是想知道:
    调用GetWindowsDirectory()获取windows目录的这个api函数
    为什么
    有时候会返回c:\WINNT(Windows   2000)或c:\Windows(Windows   2003)系统目录 
    有时候会返回当前登录用户,也就是c:\documents   and   setting\$登录用户名\windows\目录路径, 影响这个结果的原因是什么?期盼牛人到来
      

  7.   

    test
      

  8.   

    test
      

  9.   

    test
      

  10.   

    The Windows directory is the directory where an application should store initialization and help files. If the user is running a shared version of the system, the Windows directory is guaranteed to be private for each user. If an application creates other files that it wants to store on a per-user basis, it should place them in the directory specified by the HOMEPATH environment variable. This directory will be different for each user, if so specified by an administrator, through the User Manager administrative tool. HOMEPATH always specifies either the user's home directory, which is guaranteed to be private for each user, or a default directory (for example, C:\USERS\DEFAULT) where the user will have all access.