GetCurrentDirectory函数获得当前文件所在的目录,并不是进程的目录(debug 和 release),它和GetCommandLine不同
这里只讲

GetCurrentDirectory,GetCurrentDirectory是一个宏
#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的更多相关文章

  1. windows API 第22篇 WTSGetActiveConsoleSessionId

    函数原型:DWORD WTSGetActiveConsoleSessionId (VOID)先看一下原文介绍: The WTSGetActiveConsoleSessionId function re ...

  2. windows API 第13篇 MoveFileEx

    上一篇介绍了MoveFile,这次分析MoveFileEx,它是MoveFile的扩展函数,功能还要更加强大些.先看定义: BOOL WINAPI MoveFileEx( _In_     LPCTS ...

  3. Windows API 第六篇 GetLocalTime

    GetLocalTime获取系统时间信息.函数原型:VOID   WINAPI  GetLocalTime(    __out LPSYSTEMTIME lpSystemTime    ); 先来看S ...

  4. Windows API 第三篇

    1.获得程序自身的路径: DWORD GetModuleFileName( HMODULE hModule, // handle to module LPTSTR lpFilename, // pat ...

  5. Windows API 第21篇 DeleteVolumeMountPoint 删除挂载点

    函数原型:BOOL DeleteVolumeMountPoint(                                                      LPCTSTR lpszV ...

  6. Windows API 第20篇 SetVolumeMountPoint 设置卷挂载点参数错误

    函数原型:BOOL SetVolumeMountPoint(                                                   IN   LPCTSTR lpszVo ...

  7. Windows API 第20篇 GetVolumeNameForVolumeMountPoint

    函数原型: BOOL GetVolumeNameForVolumeMountPoint(                                                        ...

  8. Windows API 第19篇 FindFirstVolumeMountPoint FindNextVolumeMountPoint

    相关函数:HANDLE FindFirstVolumeMountPoint(                                                               ...

  9. windows API 第 18篇 FindFirstVolume FindNextVolume

    函数定义:Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the vol ...

随机推荐

  1. [JZOJ6272] 2019.8.4【NOIP提高组A】整除

    题目 题目大意 求方程\((x^m-x)\mod n=0\)在整数范围\([1,n]\)的解的个数. \(n=\sum_{i=1}^{c}p_i\) 给出\(c\)和\(p_i\) 思考历程 作为数论 ...

  2. [JZOJ3400] 【GDOI2014模拟】旅行

    题目 题目大意 给你一个图,让你选择权值和最小的边,使得\(1\)和\(n\),\(2\)和\(n-1\),--,\(K\)和\(n-K+1\)联通. \(K\leq 4\) 思考历程 一看到这题就觉 ...

  3. 树上思维题——cf1060E

    只要算每条路径的贡献即可 显然长度为偶数的贡献是len/2 长度为奇数的贡献是(len+1)/2 所以结果就是(sum+tot)/2 sum:路径总长 tot:奇数路径数量 怎么求奇数路径数量:只有深 ...

  4. 正则表达式 判断内容是否为合法的url

    var strUrl= "^((https|http|ftp|rtsp|mms)?://)" + "?(([0-9a-z_!~*'().&=+$%-]+: )?[ ...

  5. 缓冲(cache)和缓存(buffer)

    缓存: 指把常用数据存储到可以快速获取的区域,以备重复利用 一般叫做cache. 缓存能提高效率 缓冲: 是指在数据流转过程中,不同层次速度不一致时,利用缓冲区来缓解上下层之间速率问题(性能差异) 一 ...

  6. 安装MySql社区版(35-3)

    1,https://dev.mysql.com/ --------------------------------------------------------------------------- ...

  7. <Django> 第三方扩展

    1.富文本编辑器 tinymce为例 安装 pip install django-tinymce 在settings.py中的配置 配置应用 INSTALLED_APPS = [ 'django.co ...

  8. 创建你的 /proc 文件

    一旦你有一个定义好的 read_proc 函数, 你应当连接它到 /proc 层次中的一个入口项. 使用一个 creat_proc_read_entry 调用: struct proc_dir_ent ...

  9. CodeForces 258D Little Elephant and Broken Sorting(期望)

    CF258D Little Elephant and Broken Sorting 题意 题意翻译 有一个\(1\sim n\)的排列,会进行\(m\)次操作,操作为交换\(a,b\).每次操作都有\ ...

  10. 使用vue-cli3快速适配H5项目

    跟我老大学到了一招使用vue-cli3快速适配H5项目的方法. 我之前也有进行一个版本的适配,直接使用cnpm install -g vue-cli,然后安装各种插件进行适配,见我之前的博客. 后来老 ...