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;
  • 相关阅读:
    DataTable轉EXCEL 3/21
    中風預防知識
    unable to convert mysql date/time value to system.data.time 11/14
    win8 获得地理坐标 GIS
    页面嵌套 GIS
    win8 metro 弹出一个部分 GIS
    正则表达式基础 之 ? GIS
    windows phone pivot 开发过程中的使用心得 GIS
    线程不安全 GIS
    线程基础知识 GIS
  • 原文地址:https://www.cnblogs.com/priarieNew/p/9754428.html
Copyright © 2011-2022 走看看