zoukankan      html  css  js  c++  java
  • windows API 第 11 篇 GetCurrentDirectory SetCurrentDirectory

    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,
    如果缓冲区的长度不够,则函数返回实际需要的缓冲区大小,包括''。
    //设置当前目录:
    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;
  • 相关阅读:
    携程机票实时数据处理实践及应用
    关系型数据库表设计
    tornado
    Poisson distribution 泊松分布 指数分布
    Interpret bytes as packed binary data
    python爬虫爬取内容中,-xa0,-u3000的含义
    Okapi BM25 (BM stands for Best Matching)
    一主
    分片 副本
    暂时无法提交申请 帐号类型修改
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9754428.html
Copyright © 2011-2022 走看看