我在使用GetModuleFileName的路径中获得了\.\ ... [英] I'm getting a \.\ in the path using GetModuleFileName...

查看:96
本文介绍了我在使用GetModuleFileName的路径中获得了\.\ ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在将应用程序从Visual C ++ 6移植到Visual C ++ 2010。



在我正在使用的应用程序中:



Hello all,

I'm porting an application from "Visual C++ 6" to "Visual C++ 2010".

In that application I'm using:

char    szAppPath[MAX_PATH] = "";
CString strAppDirectory;

::GetModuleFileName(0, szAppPath, sizeof(szAppPath) - 1);
strAppDirectory = szAppPath;
m_csPathApp = strAppDirectory.Left(strAppDirectory.ReverseFind('\\'));





获取应用程序路径,但我得到类似的东西:c:\ project] \ my_app \。\ 调试当然没有什么工作从那一点开始。 (粗体和大字体的部分应替换为 \ )。



之前有效(VC ++ 6),当然我可以搜索\.\并将其替换为\但我想避免这种情况,因为我猜这里我做错了。 ..



使用visual C ++ 2010获取应用程序路径搜索谷歌没有运气,我甚至在几个页面中看到了常见问题解答和教程(Codeguru,堆栈溢出,。 ..)他们建议我的方法...



任何想法或建议?



提前谢谢,



To get the applciation path, but I'm getting something like: "c:\projects\my_app\.\Debug" and of course nothing is working from that point. (The part in bold and big fonts should be replaced by \).

It was working before (VC++6), and, of course I can search for "\.\" and replace it for "\" but I would like to avoid that as I'm guessing I'm doing something wrong here...

Searched google using "visual C++ 2010 get application path" Without luck, I've even seen FAQs and tutorials in several pages (Codeguru, stack overflow,...) in which they were suggesting my approach...

Any idea or advice?

Thank you in advance,

推荐答案

路径c:\ project] \ my_app \.\Debug是完全合法的,相当于c: \projects\my_app\Debug。



尝试以下命令:

The path "c:\projects\my_app\.\Debug" is perfectly legal and is equivalent to "c:\projects\my_app\Debug".

Try the following commands:
cd c:\projects\my_app\.\Debug



and

cd c:\projects\my_app\Debug



如果路径存在,您会看到他们将工作目录更改为同一个地方。



如果你觉得什么都没有,原因就不一样了。



-SA

我已经完成了上述讨论,我建议你使用像
I have gone through the above discussion and I suggest you to use the macros like


(OutDir)这样的宏,
(OutDir),


这篇关于我在使用GetModuleFileName的路径中获得了\.\ ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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