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. ERROR 1872

    解决 > start slave; ERROR (HY000): Slave failed to initialize relay log info structure from the rep ...

  2. mysql Slave 启动失败

    报错日志 Slave failed to initialize relay log info structure java程序访问日志显示事物查询失败,排查mysql 发现其中一台slave 启动状态 ...

  3. 【JZOJ5431】序列操作

    description 一开始有n个非负整数hi,接下来会进行m次操作,第i次操作给出一个数c[i],要求你选出c[i]个大于零的数并将它们减去1. 问最多可以进行多少轮操作后无法操作(即没有c[i] ...

  4. You can tell a lot about somebody, looking him in the eye.

    You can tell a lot about somebody, looking him in the eye.注视着别人的眼睛,你能读出很多故事.

  5. php设置时区和strtotime转化为时间戳函数

    date_default_timezone_set('PRC');//设置中华人民共和国标准时间 strtotime — 将任何英文文本的日期时间描述解析为 Unix 时间戳 格式:int strto ...

  6. 网页存储倒计时与解决网页cookie保存多个相同key问题

    短信倒计时多用网页临时存储,这可以保证网页在关闭状态也可记时. <p class="test_button" id="getcode">获取验证码& ...

  7. 三模数NTT模板

    求两个多项式的卷积对任意数p取模 两个好记的FNT模数: 5*2^25+1 7*2^26+1 原根都为3 //Achen #include<algorithm> #include<i ...

  8. day22_4-pickle模块

    # 参考资料:# python模块(转自Yuan先生) - 狂奔__蜗牛 - 博客园# https://www.cnblogs.com/guojintao/articles/9070485.html ...

  9. vue+el-menu+vue-router实现动态导航条

    导航栏组件template <template> <div class="sidebar"> <el-menu unique-opened :defa ...

  10. linux xargs命令一(与find ls等命令组合)(转)

    -p 操作具有可交互性,每次执行comand都交互式提示用户选择 -i -i 选项告诉 xargs 可以使用{}代替传递过来的参数, 建议使用-I,其符合POSIX标准 -I 格式: xargs  - ...