怎样获得windows中环境变量TEMP的值?怎么搞啊?谢谢。。谁告诉我。。100分全给他。。:)不成敬意:)
解决方案 »
- mfc 同类函数调用
- 准备找工作中,:)有几个题说的不是太明白,大家帮忙看看
- 请问UDP通讯,如何能在内网向外网服务器发数据,外网服务器如何能向内网发数据
- 请给DDB举个例子?比如DIB有BMP文件,但DDB有哪些?
- Control support中的CDockState类 和CImageList类 是不是应该归类于 CWnd类???
- 代理服务器上网,怎样编程实现用smtp发送email呢?
- 关于系统修改的小问题,请问如何更改windows的分辨率呢?
- ■■■■关于 CDialog 使用
- 各位高人!请指点!如何使用VC来锁定桌面,并且在不重新启动计算机的情况下给它解锁。
- 奇怪的问题:MFC,多线程,Socket,变量存取的问题?
- vc Active X编写的ocx 在容器中能够打开正常,而在regsrv32 注册时却无法找到
- 如何用CDatabase连接数据库时不使用ODBC进行连接,而是直接连接数据库文件,我的数据库是Access 2000?
SetEnviromentVariable()
GetEnviromentVariable()
DWORD nBufferLength, // size of buffer
LPTSTR lpBuffer // path buffer
);
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.
::GetEnvironmentVariable(_T("TEMP"), lpszBuf, sizeof(lpszBuf) / sizeof(TCHAR)); 我是这么做的,但是我想用AfxMessageBox把TEMP的值显示出来。。还应该做些什么呢?。
::GetEnvironmentVariable(_T("TEMP"), lpszBuf, sizeof(lpszBuf) / sizeof(TCHAR)); 我是这么做的,但是我想用AfxMessageBox把TEMP的值显示出来。。还应该做些什么呢?。
#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++做的很小的范例
应该会用了吧
你自己运行一下吧