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 ...
随机推荐
- openwrt MySQL移植
1 选择包 选择两个包,拷贝配置文件 cp products/mt7621/config_6080 .config 编译固件 openwrt 百万数据的优化, 执行脚本: mysql -u root ...
- Largest Submatrix
Largest Submatrix 给出一个\(n\times m\)的网格,网格里只放有字符a,b,c,d,w,x,,z,现在你可以将其中的w换成a,b,把x换成b,c,把y换成a,c,把z换成a, ...
- python中的 += 语法的使用
python中有个缩略的写法,如下 a = a +1 等同于 a +=1 发现了一个有趣之处,+=的写法中间不能有空格,否则报错,测试如下 Python 3.7.1 (v3.7.1:260ec2c36 ...
- leetcode-157周赛-5214-最长定差子序列
题目描述: class Solution: def longestSubsequence(self, arr: List[int], difference: int) -> int: dp = ...
- CSS——元素的显示与隐藏
元素的显示与隐藏 在CSS中有三个显示和隐藏的单词比较常见,我们要区分开,他们分别是 display visibility 和 overflow. 他们的主要目的是让一个元素在页面中消失,但是不在文档 ...
- day27 模块:正则re, configparser, subprocess
Python之路,Day15 = Python基础15 re 模块补充 ret = re.findall("c.d", "abc\nd", re.S) # 后面 ...
- vue.js出现cannot get /错误
config中的index.js 原来是 assetsPublicPath: './', 改为 assetsPublicPath: '/',
- SPSS分析:Bootstrap
SPSS分析:Bootstrap 一.原理: 非参数统计中一种重要的估计统计量方差进而进行区间估计的统计方法,也称为自助法.其核心思想和基本步骤如下: 1.采用重抽样技术从原始样本中抽取一定数量(自己 ...
- 微信小程序 tabBar模板
tabBar导航栏 小程序tabBar,我们可以通过app.json进行配置,可以放置于顶部或者底部,用于不同功能页面的切换,挺好的... 但,,,貌似不能让动态修改tabBar(需求:通过switc ...
- google浏览器插件开发
官方开发文档 随便找个文件夹新建插件所需文件 目录结构 pluginName manifest.json(必须) 一个manifest文件 *.htm ...