我希望在程序中得到当前可执行文件的路径,该怎么办? 程序开始运行时GetCurrentDirectory() 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我试过这个办法,不过打开文件或者保存文件之后,这个函数的返回值就变了.VB 中可以使用 App.Path ,VC中就没有办法了? char strFileName[100]; GetModuleFileName(NULL,strFileName,100); ::MessageBox(NULL,strFileName,"22",MB_OK); 这个问题都说啦好几次啦,是seesi的方法,在处理一下,因为它得到的是整个路径和文件名。 char szFileFullPath[MAX_PATH]; ::GetModuleFileName(NULL, szFileFullPath, MAX_PATH); CString szFilePath(szFileFullPath); int nPos = szFilePath.ReverseFind('\\'); szFilePath = szFilePath.Left(nPos); AfxMessageBox(szFileFullPath); AfxMessageBox(szFilePath); 或:szFilePath = szFilePath.Left(nPos + 1); 呵呵,wbc_58(我是我)把VC和DELPHI搞混了吧? 自己写的函数,忘记了CString CMyDlg::GetExeFilePath(){ TCHAR buffer[1024]; GetModuleFileName(AfxGetInstanceHandle(),buffer,1024); return CString(buffer);} 怎样得到程序的当前路径 #include < windows.h >#include < string.h > HINSTANCE hInst;char szBuf[256];char *p; //拿到全部路径GetModuleFileName(hInst,szBuf,sizeof(szBuf)); //分离路径和文件名。p = szBuf;while(strchr(p,'\\')) {p = strchr(p,'\\');p++;}*p = '\0';//路径在szBuf理了。 請問VC++的windowform能否獨立運行呢!怎麼做呢? 初学多线程调试时碰到的错误。。求解?! vc 关于字体的几个问题 串口和并口怎么翻译?急!!!谢谢 用DDraw遇到麻烦了!! lpdd->QueryInterface(IID_IDirectDraw7... IID_IDirectDraw7却联接不上!? 一个超简单的文件读写问题求助? 新手问题 帮忙谢谢 哎呀,最基本的问题忘了,谁帮我讲讲输出格式。 简单问题:如何修改资源中菜单的名称 高难度的菜单问题! 请问如何在VC中实现定时中断? switch...case中怎么用字符串?谁有变通的解决办法?
VB 中可以使用 App.Path ,VC中就没有办法了?
GetModuleFileName(NULL,strFileName,100);
::MessageBox(NULL,strFileName,"22",MB_OK);
::GetModuleFileName(NULL, szFileFullPath, MAX_PATH);
CString szFilePath(szFileFullPath);
int nPos = szFilePath.ReverseFind('\\');
szFilePath = szFilePath.Left(nPos);
AfxMessageBox(szFileFullPath);
AfxMessageBox(szFilePath);
szFilePath = szFilePath.Left(nPos + 1);
CString CMyDlg::GetExeFilePath()
{
TCHAR buffer[1024];
GetModuleFileName(AfxGetInstanceHandle(),buffer,1024);
return CString(buffer);
}
#include < windows.h >
#include < string.h > HINSTANCE hInst;
char szBuf[256];
char *p; //拿到全部路径
GetModuleFileName(hInst,szBuf,sizeof(szBuf)); //分离路径和文件名。
p = szBuf;
while(strchr(p,'\\')) {
p = strchr(p,'\\');
p++;
}
*p = '\0';
//路径在szBuf理了。