当前目录 [英] current directory

查看:83
本文介绍了当前目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取当前正在运行的可执行文件的目录路径.

get the directory path of current executable file running.

推荐答案

如果您需要应用程序当前目录,则调用GetCurrentDirectory [正在运行的当前可执行文件的目录路径",则可以调用 ^ ]函数,然后从路径中删除文件名.
:)
If you need the application current directory then call GetCurrentDirectory[^] function.

On the other hand, if you need ''the directory path of current executable file running'' then you may call the GetModuleFilename[^] function and then remove the filename from the path.
:)


下面的代码为您提供当前进程的 exe 文件所在的路径:

The code below gives you the path where the exe file of the current process is located:

TCHAR szFilename[MAX_PATH];
GetModuleFileName(NULL, szFilename, MAX_PATH);
PathRemoveFileSpec(szFilename);



请注意,如果您从 dll 使用此代码,则会获得加载该库的 exe 文件的路径,而不是 dll 的路径. b>是.



Note that if you use this code from a dll, you get the path of the exe file that loaded the library, and not the path where the dll is.


这篇关于当前目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆