如何确定Windows和Windows系统目录
来源:互联网 发布:ssl默认端口号 编辑:程序博客网 时间:2024/06/05 20:42
有两个SDK函数可以完成该功能。GetWindowsDirectory和GetSystemDirectory,
TCHAR szDir [MAX_PATH];
//Get the full path of the windows directory.
:: GetWindowsDirectory (szDir, MAX_PATH);
TRACE ("Windows directory %s/n", szDir);
//Get the full path of the windows system directory.
:: GetSystemDirectory (szDir, MAX_PATH);
:: GetSystemDirectory (szDir, MAX_PATH);
调用SDK函数GetTemPath可以确定临时文件的目录,该函数首先为临时路径
检测TMP环境变量:如果没有指定TMP,检测TMP环境变量,然后返回到当前目录。
下例说明了如何创建一个临时文件。
…
//get unique temporary file.
CString strFile;
TRY
{
//Create file and write data.Note that file is closed
//in the destructor of the CFile object.
//write data
CATCH (CFileException, e)
CATCH (CFileException, e)
{
//error opening file
}
END_CATCH
Void GetuniqueTempName (CString& strTempName)
{
//Get the temporary files directory.
TCHAR szTempPath [MAX_PATH];
DWORD dwResult=:: GetTempPath (MAX_PATH, szTempPath);
//Create a unique temporary file.
TCHAR szTempFile [MAX_PATH];
UINT nResult=GetTempFileName (szTempPath, _T ("~ex"),0,szTempfile);
strTempName=szTempFile;
}
TCHAR szDir [MAX_PATH];
//Get the full path of the windows directory.
:: GetWindowsDirectory (szDir, MAX_PATH);
TRACE ("Windows directory %s/n", szDir);
//Get the full path of the windows system directory.
:: GetSystemDirectory (szDir, MAX_PATH);
:: GetSystemDirectory (szDir, MAX_PATH);
调用SDK函数GetTemPath可以确定临时文件的目录,该函数首先为临时路径
检测TMP环境变量:如果没有指定TMP,检测TMP环境变量,然后返回到当前目录。
下例说明了如何创建一个临时文件。
…
//get unique temporary file.
CString strFile;
TRY
{
//Create file and write data.Note that file is closed
//in the destructor of the CFile object.
//write data
CATCH (CFileException, e)
CATCH (CFileException, e)
{
//error opening file
}
END_CATCH
Void GetuniqueTempName (CString& strTempName)
{
//Get the temporary files directory.
TCHAR szTempPath [MAX_PATH];
DWORD dwResult=:: GetTempPath (MAX_PATH, szTempPath);
//Create a unique temporary file.
TCHAR szTempFile [MAX_PATH];
UINT nResult=GetTempFileName (szTempPath, _T ("~ex"),0,szTempfile);
strTempName=szTempFile;
}
- 如何确定Windows和Windows系统目录
- 如何确定Windows和Windows系统目录
- 如何确定Windows和Windows系统目录
- 获取系统目录和Windows目录
- Windows 系统目录简写
- 复制自身程序到windows目录和系统目录下
- 复制自身程序到Windows目录和系统目录下
- windows下如何确定程序占用端口
- Windows下如何确定用户创建时间
- Windows系统如何查IP和DNS
- Windows系统如何查IP和DNS
- vc 获得windows系统目录
- windows系统删除subversion目录
- Cygwin在windows系统下编译Linux程序以及访问windows系统目录和软件
- 了解你的windows目录和系统文件.txt
- 了解你的windows目录和系统文件
- 如何修改windows收藏夹目录?
- Windows下如何改变目录
- 如何获取一个对话控件的指针
- 如何改变控件的字体
- 如何在OLE控件中使用OLE_COLOR数据类型
- Hibernate 关系配置
- 如何访问桌面窗口
- 如何确定Windows和Windows系统目录
- 如何检索原先的Task Manager应用程序使用的任务列表
- ubuntu安装配置手记
- 如何使用一个预定义的Windows光标
- 如何一个创建三态下压按钮
- 如何动态创建控件
- Custom Membership Provider under Minimal Trust in SharePoint 2007
- 如何限制编辑框中的准许字符
- 严重: IOException while loading persisted sessions: java.io.EOFException解决方案