GetCurrentDirectory 理解
来源:互联网 发布:linux工程师 编辑:程序博客网 时间:2024/06/09 15:00
//====================================GetCurrentDirectory============================//
/*
GetCurrentDirectory它表示当前目录 打开哪就是哪
文件路径 需要再操作,如C:/windows 不需要处理转义符 strcat(lpStr,"//XXX.txt");
GetCurrentDirectory只是获取当前的目录,当计算机重新启动后,当前的路径一般为系统目录,因此系统启动后,
使用该函数只能获取当前的目录,而不是应用程序所在的目录。
我建议你使用GetModuleFileName函数,GetModuleFileName()是一个得到路径的API 函数。
DWORD GetCurrentDirectory(_in DWORD nBufferSize , _out LPCSTR lpBuffer);
lpBuffer return the current process directory.
returns Can judge the state of the function. returns means the bytes lpBuffer read really,if this function is success.
returns may stand for the bytes needs for the directory space ,if this function is failed.
else,you may call the function GetLastError Judge the reason
the direction may be
*/
#include<iostream>
#include<windows.h>
using namespace std;
#define nSize 60
void main()
{
CHAR lpStr[nSize]; //allocate the space for the directory
DWORD nPathSize=0; //record the returns of the function,which is used to judge the state of the function.
memset(lpStr,0,nSize); //space init
nPathSize = GetCurrentDirectory(nSize,lpStr);
if(nPathSize<nSize)
cout<<lpStr<<endl;
else
cout<<"need space is "<<nPathSize<<endl;
system("pause");
}
- GetCurrentDirectory 理解
- GetCurrentDirectory
- GetCurrentDirectory()
- GetModuleFileName& GetCurrentDirectory
- GetCurrentDirectory function
- GetModuleFileName& GetCurrentDirectory
- GetCurrentDirectory Function
- GetCurrentDirectory & GetModuleFileName
- GetCurrentDirectory,SetCurrentDirectory
- GetCurrentDirectory获得当前目录
- GetCurrentDirectory的使用(SDK)
- GetCurrentDirectory和SetCurrentDirectory函数
- GetCurrentDirectory的一个问题
- GetCurrentDirectory 与GetModuleFileName
- GetCurrentDirectory 和 GetModuleFileName 区别
- GetCurrentDirectory 和 GetModuleFileName区别
- GetCurrentDirectory、SetCurrentDirectory和GetModuleFileName
- GetCurrentDirectory和SetCurrentDirectory
- 在Window XP上搭建Android开发环境
- oracle死锁查询及处理
- 使当前用户具有超级管理员权限
- Struts2中使用总结
- 本人译著《iPhone SDK编程入门经典:使用Objective-C》现已出版
- GetCurrentDirectory 理解
- 【新生指南】福建师范大学新生入学手册--【师大搜索-整理】
- sql循环生成id和delphi生成最大编号
- 深入剖析PE文件
- IT项目开发团队建设与管理总结
- DBSet的mock
- physdiskwrite使用教程
- 本人译著《Professional Xcode 3》现已翻译完毕
- 把字符串中所有小写字母转换成大写,其余不变,不能用Stirng.toUpperCase()方法