📄 subject_61490.htm
字号:
<p>
序号:61490 发表者:kknd 发表日期:2003-11-20 08:30:13
<br>主题:我如何获得正在执行的可执行文件所在路径?
<br>内容:如果用GetCurrent(),是否可以,如果我用桌面快捷方式执行?又如何得到?
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:秋叶禅 回复日期:2003-11-20 08:33:35
<br>内容:如果你想不管用什么方式执行?想得到程序运行的真正的路径:<BR>用:<BR>char DirName1[1000] = {0};<BR>strcpy(DirName1,__argv[0]); <BR>__argv[0]中保存的就是程序真正的执行路径,不管你用什么方式执行。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:樂日華 回复日期:2003-11-20 08:38:22
<br>内容:CString CStructProc::GetExePath()<BR>{<BR> char DBFileName[MAX_PATH];<BR> GetModuleFileName(AfxGetInstanceHandle(), DBFileName, MAX_PATH);<BR> CString m_strExePath;<BR> m_strExePath = DBFileName;<BR> m_strExePath = m_strExePath.Mid(0, m_strExePath.ReverseFind('\\'));<BR> return m_strExePath;<BR>}<BR><BR>m_strExePath 就是當前程序運行的路徑.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:浪际天涯 回复日期:2003-11-20 09:55:03
<br>内容:GetCurrentDirectory获取到的不一定是程序当前路径,有时候你在程序中open选择一个文件后,用GetCurrentDirectory获取到的就是该文件所在目录了。<BR> char modulfile[200];<BR> ::GetModuleFileName(NULL,modulfile,200);<BR> CString strname=modulfile;//可执行文件全路径,包括文件名<BR> CString exepath=strname.Left(strname.ReverseFind('\\'));//不包括文件名<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:樂日華 回复日期:2003-11-20 12:39:47
<br>内容:上面的程序有問題嗎? <BR>m_strExePath = m_strExePath.Mid(0, m_strExePath.ReverseFind('\\'));<BR>你知道我這句是干什麼用的嗎?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:浪际天涯 回复日期:2003-11-20 15:17:42
<br>内容:2楼的程序也没有问题,一样的效果
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:萨达姆的黑手掌 回复日期:2003-11-20 15:24:36
<br>内容:to:樂日華<BR>你是台湾人嘛?喜欢用繁体?我看也挺好看的,用什么输入法打的啊?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -