码迷,mamicode.com
首页 > 其他好文 > 详细

GetModuleFileNameA()与GetCurrentDirectoryA()

时间:2014-07-23 16:47:41      阅读:369      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   strong   文件   

头文件: #include <windows.h>

GetModuleFileNameA()
char moduleFileName[MAX_PATH];     
GetModuleFileNameA(0, moduleFileName, MAX_PATH);

取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects 
\Test\debug\Test.exe

 

    char moduleFileName[MAX_PATH];     
    GetModuleFileNameA(NULL, moduleFileName, MAX_PATH);     
    std::string workingFolder(moduleFileName);     
    size_t pos = workingFolder.find_last_of("\\");     
    workingFolder = workingFolder.substr(0, pos+1);     
    std::cout<<workingFolder<<std::endl;    

取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects 
\Test\debug\

 

GetCurrentDirectoryA()
char result[MAX_PATH];     
GetCurrentDirectoryA(MAX_PATH, result);

取得的路径为:c:\Documents and Settings\Administrator\My Documents\Visual Studio 2010\Projects 
\Test\Test 

GetModuleFileNameA()与GetCurrentDirectoryA(),布布扣,bubuko.com

GetModuleFileNameA()与GetCurrentDirectoryA()

标签:style   blog   color   os   strong   文件   

原文地址:http://www.cnblogs.com/lxt287994374/p/3863303.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!