怎样获得windows中环境变量TEMP的值?怎么搞啊?谢谢。。谁告诉我。。100分全给他。。:)不成敬意:)

解决方案 »

  1.   


    SetEnviromentVariable()
    GetEnviromentVariable()
      

  2.   

    DWORD GetTempPath(
      DWORD nBufferLength,  // size of buffer
      LPTSTR lpBuffer       // path buffer
    );
      

  3.   

    就是右键点“我的电脑”-->属性-->高级页面中。。那个TEMP的值啊。用程序怎么获得啊?
      

  4.   

    晕哦,大家讲的方法都是针对你的问题,自己trytry
      

  5.   


    GetEnviromentVariable()
    来自msdn
    =====================
    The GetEnvironmentVariable function retrieves the value of the specified variable from the environment block of the calling process. The value is in the form of a null-terminated string of characters.DWORD GetEnvironmentVariable(
      LPCTSTR lpName,  // environment variable name
      LPTSTR lpBuffer, // buffer for variable value
      DWORD nSize      // size of buffer
    );
    Parameters
    lpName 
    [in] Pointer to a null-terminated string that specifies the environment variable. 
    lpBuffer 
    [out] Pointer to a buffer to receive the value of the specified environment variable. 
    nSize 
    [in] Specifies the size, in TCHARs, of the buffer pointed to by the lpBuffer parameter. 
    Return Values
    If the function succeeds, the return value is the number of TCHARs stored into the buffer pointed to by lpBuffer, not including the terminating null character. If the specified environment variable name was not found in the environment block for the current process, the return value is zero. If the buffer pointed to by lpBuffer is not large enough, the return value is the buffer size, in TCHARs, required to hold the value string and its terminating null character. For example, see Changing Environment Variables. 
      

  6.   

    TCHAR lpszBuf[128];
    ::GetEnvironmentVariable(_T("TEMP"), lpszBuf, sizeof(lpszBuf) / sizeof(TCHAR)); 我是这么做的,但是我想用AfxMessageBox把TEMP的值显示出来。。还应该做些什么呢?。
      

  7.   

    怎么把TEMP的值取出来呢?他保存在哪里呢?高手帮忙
      

  8.   

    TCHAR lpszBuf[128];
    ::GetEnvironmentVariable(_T("TEMP"), lpszBuf, sizeof(lpszBuf) / sizeof(TCHAR)); 我是这么做的,但是我想用AfxMessageBox把TEMP的值显示出来。。还应该做些什么呢?。
      

  9.   

    #include <iostream.h>
    #include <windows.h>void main()
    {DWORD nBufferLength=256;
    char* lpBuffer=new char[256];
    GetTempPath(nBufferLength,(LPTSTR)lpBuffer );      // path buffer
    cout<<lpBuffer<<endl;delete[]lpBuffer;
    }这是我用c++做的很小的范例
    应该会用了吧
    你自己运行一下吧