windows API 第 11 篇 GetCurrentDirectory SetCurrentDirectory
GetCurrentDirectory函数获得当前文件所在的目录,并不是进程的目录(debug 和 release),它和GetCommandLine不同
这里只讲
#ifdef UNICODE
#define GetCurrentDirectory GetCurrentDirectoryW
#else
#define GetCurrentDirectory GetCurrentDirectoryA
#endif // !UNICODE
看一下定义:
//获得当前文件所在目录:
DWORD GetCurrentDirectory(
DWORD nBufferLength, // size of directory buffer
LPTSTR lpBuffer // directory buffer);
参数都比较简单,不做过多的介绍。
返回值:调用成功则返回写入lpBuffer的字符个数,不包括'\0',失败则返回0,
如果缓冲区的长度不够,则函数返回实际需要的缓冲区大小,包括'\0'。
//设置当前目录:
BOOL SetCurrentDirectory( LPCTSTR lpPathName // new directory name
);
举例说明:
char szDir1[MAX_PATH] = { 0 };
DWORD dwLen1 = GetCurrentDirectoryA(MAX_PATH, szDir1);
WCHAR *pDir2 = NULL;
DWORD dwLen2 = GetCurrentDirectory(0, pDir2);
pDir2 = new WCHAR[dwLen2];
DWORD dwLen = GetCurrentDirectory(dwLen2, pDir2);
delete []pDir2;
windows API 第 11 篇 GetCurrentDirectory SetCurrentDirectory的更多相关文章
- windows API 第22篇 WTSGetActiveConsoleSessionId
函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...
- windows API 第13篇 MoveFileEx
上一篇介绍了MoveFile,这次分析MoveFileEx,它是MoveFile的扩展函数,功能还要更加强大些.先看定义: BOOL WINAPI MoveFileEx( _In_ LPCTS ...
- Windows API 第六篇 GetLocalTime
GetLocalTime获取系统时间信息.函数原型:VOID WINAPI GetLocalTime( __out LPSYSTEMTIME lpSystemTime ); 先来看S ...
- Windows API 第三篇
1.获得程序自身的路径: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // pat ...
- Windows API 第21篇 DeleteVolumeMountPoint 删除挂载点
函数原型:BOOL DeleteVolumeMountPoint( LPCTSTR lpszV ...
- Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误
函数原型:BOOL SetVolumeMountPoint( IN LPCTSTR lpszVo ...
- Windows API 第20篇 GetVolumeNameForVolumeMountPoint
函数原型: BOOL GetVolumeNameForVolumeMountPoint( ...
- Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint
相关函数:HANDLE FindFirstVolumeMountPoint( ...
- windows API 第 18篇 FindFirstVolume FindNextVolume
函数定义:Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the vol ...
随机推荐
- Java 基础 - Exception和Error
综述 Exception 和 Error 都是继承了 Throwable 类,在 Java 中只有 Throwable 类型的实例才可以被抛出(throw)或者捕获(catch),它是异常处理机制的基 ...
- Java 多线程 - 创建线程的方法 + Executors.newXXXThreadPool()缺点
java中创建线程的三种方法以及区别: https://www.cnblogs.com/3s540/p/7172146.html 通过Executor 的工具类,创建三种类型的普通线程池: https ...
- Tomcat的8080、8005、8009端口
8080是http 1.1 connector,也就是接收处理http请求的端口,如果你只用一个tomcat处理所有请求,可以只使用这个connector. 8005是 tomcat接受关闭指令的端口 ...
- 「APIO 2019」路灯
题目 显然一个熟练的选手应该能一眼看出我们需要维护点对的答案 显然在断开或连上某一条边的时候只会对左右两边联通的点产生贡献,这个拿\(set\)维护一下就好了 那现在的问题就是怎么维护了 考虑一个非常 ...
- js 实现vue—引入子组件props传参
参考:https://www.cnblogs.com/xiaohuochai/p/7388866.html 效果 html <!DOCTYPE html> <html> < ...
- Redis单机和集群配置(版本在5.0后)
摘抄并用于自己后查 单机版的配置: 1. 下载redis压缩包,然后解压缩文件(tar xzf): 2. 进入解压后的redis文件目录,编译redis源文件(make,没有c环境要gcc): 3. ...
- 锋利的Jquery(Table,Checkbox)
1.Table奇数偶数行 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...
- js判断客服端
ua: function () { return navigator.userAgent.toLowerCase() }, ...
- docker 个人遇到问题日志记录
system: openSUSE Leap 42.3 在openSUSE中可直接运行" sudo zypper in docker"进行安装docker-ce wakasann@l ...
- es6 + 笔记整理
1. ES6提供了默认参数值机制,允许你为参数设置默认值,防止在函数被调用时没有传入这些参数: const required = () => {throw new Error('Missing ...