得到当前的路径 [英] get current path

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

问题描述

任何函数都可以告诉编译程序执行路径吗?使用

程序从MFC对话框中打开文件后,路径会发生变化。在

预付款。

Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.

推荐答案

" kk" < KK ****** @ cuhk.edu.hk>写道:
"kk" <kk******@cuhk.edu.hk> writes:
任何函数都可以告诉编译程序执行路径吗?使用
程序从MFC对话框中打开文件后,路径会发生变化。
提前。
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.




我们不知道。你的问题似乎与C

编程语言无关,所以我们不能在这里回答。试试新闻组

他们谈论MFC(无论是什么)。


-

Keith Thompson(The_Other_Keith)< a href =mailto:ks *** @ mib.org> ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。



We don''t know. Your question doesn''t seem to be about the C
programming language, so we can''t answer it here. Try a newsgroup
where they talk about MFC (whatever that is).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.


kk写道:
任何函数都可以告诉编译程序执行路径吗?使用
程序从MFC对话框中打开文件后,路径会发生变化。提前
提前。
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.



我只处理过一次这种情况而且找不到解决方案

抢执行路径作为执行路径。然而,我确实找到了一个

方式来获取当前路径(虽然现在我的思绪滑落了我的想法

并且它是在Linux中完成的,而不是Windows),但是你可以首先获取执行

路径,然后让你的程序做任何需要做的事情,Msft

基础课不是站着的。


TheMusikMan


I have only dealt with the situation once and didn''t find a solution to
grab the execution path "as the execution path". I did however, find a
way to grab the current path (though the call slips my mind right now
and it was done in Linux, not Windows), but you can grab the execution
path first thing, then let your program do whatever it needs to do, Msft
Foundation Classes not-with-standing.

TheMusikMan


kk写道:
kk wrote:
任何函数都可以告诉编译程序执行路径吗?使用
程序从MFC对话框中打开文件后,路径会发生变化。提前
提前。
Can any function tell the compiled program executing path? after using the
program to open a file from MFC dialog box, the path changes. thks in
advance.





#include< direct.h>


....

_getcwd(int buflen,char * pathbuffer);


这会将当前路径放入pathbuffer到buflen chars。


然后有

_chdir(char * path);


将设置当前路径给定一个。


避免改变路径的一种方法是在

调用文件打开对话框之前获取路径,然后设置保存路径<对话框存在后,
一个。


但更简单的方法是告诉程序不要更改

路径。文件打开对话框有一个标志,以避免更改路径

查看SDK文档。


jacob


You
#include <direct.h>

....
_getcwd(int buflen, char *pathbuffer);

This will put the current path into pathbuffer up to buflen chars.

Then there is
_chdir(char *path);

that will set the current path to the given one.

One way to avoid changing the path is to get the path before
calling the file open dialog, then setting the path to the saved
one after the dialog exists.

But a more simpler way is to tell the program not to change the
path. The file open dialog has a flag to avoid changing the path
Look in the SDK documentation.

jacob

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

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