获取当前应用程序路径
2007-06-01 19:32
369 查看
1,
char FileName[1024];GetCurrentDirectory(1024,FileName);
CString AppPath =FileName;
2,
HMODULE hModule=(HMODULE)AfxGetApp()->m_hInstance;
char lpFn[100];
// HANDLE hFile;
::GetModuleFileName(hModule,lpFn,100);
3,
char szFilename[MAX_PATH];
DWORD dwPathLen = 0;
if((dwPathLen = ::GetModuleFileName(
::AfxGetInstanceHandle(),
szFilename,
MAX_PATH
)) == 0) {
return FALSE;
}
for(int i=dwPathLen-1; i>=0; i--) {
if(('//' == szFilename[i])
|| ('/' == szFilename[i])) {
break;
} else {
szFilename[i] = '/0';
}
}
AfxMessageBox(szFilename);
4,
CString GetAppPath()
{
CString m_sCPath,str ;
char dir[300] ;
HINSTANCE hpin= AfxGetInstanceHandle() ;
GetModuleFileName(hpin,dir,299);
m_sCPath = dir ;//当前路径
str = AfxGetApp()->m_pszExeName;
str = str+".exe" ;
m_sCPath.MakeLower() ;
str.MakeLower() ;
int ipos ;
ipos = m_sCPath.Find(str ) ;
m_sCPath.Delete(ipos ,str.GetLength()) ;
if ( m_sCPath.Right(1)!='//')
{
m_sCPath = m_sCPath+"//" ;
}
return m_sCPath ;
}
char FileName[1024];GetCurrentDirectory(1024,FileName);
CString AppPath =FileName;
2,
HMODULE hModule=(HMODULE)AfxGetApp()->m_hInstance;
char lpFn[100];
// HANDLE hFile;
::GetModuleFileName(hModule,lpFn,100);
3,
char szFilename[MAX_PATH];
DWORD dwPathLen = 0;
if((dwPathLen = ::GetModuleFileName(
::AfxGetInstanceHandle(),
szFilename,
MAX_PATH
)) == 0) {
return FALSE;
}
for(int i=dwPathLen-1; i>=0; i--) {
if(('//' == szFilename[i])
|| ('/' == szFilename[i])) {
break;
} else {
szFilename[i] = '/0';
}
}
AfxMessageBox(szFilename);
4,
CString GetAppPath()
{
CString m_sCPath,str ;
char dir[300] ;
HINSTANCE hpin= AfxGetInstanceHandle() ;
GetModuleFileName(hpin,dir,299);
m_sCPath = dir ;//当前路径
str = AfxGetApp()->m_pszExeName;
str = str+".exe" ;
m_sCPath.MakeLower() ;
str.MakeLower() ;
int ipos ;
ipos = m_sCPath.Find(str ) ;
m_sCPath.Delete(ipos ,str.GetLength()) ;
if ( m_sCPath.Right(1)!='//')
{
m_sCPath = m_sCPath+"//" ;
}
return m_sCPath ;
}
相关文章推荐
- [C#]使用 C# 代码实现拓扑排序 dotNet Core WEB程序使用 Nginx反向代理 C#里面获得应用程序的当前路径 关于Nginx设置端口号,在Asp.net 获取不到的,解决办法 .Net程序员 初学Ubuntu ,配置Nignix 夜深了,写了个JQuery的省市区三级级联效果
- C#获取当前应用程序所在路径及环境变量
- c#获取当前应用程序所在路径
- Winform获取应用程序的当前路径方法集合
- C#获取当前应用程序所在路径及环境变量
- C#获取当前应用程序所在路径及环境变量
- JAVA应用程序获取当前路径
- C#获取当前应用程序启动路径的方法
- C#获取当前应用程序所在的路径
- C#获取当前应用程序所在的路径
- C#获取当前应用程序所在路径及环境变量
- c#获取当前应用程序所在路径(转)
- C#获取当前应用程序所在的路径
- C#获取当前应用程序所在路径及环境变量
- C#、ASP.NET获取当前应用程序的绝对路径
- 获取当前正在执行的服务器应用程序根目录的物理文件系统路径
- C#获取当前应用程序所在路径及环境变量
- 【转】c#获取当前应用程序所在路径
- java 获取当前应用程序路径
- Linux C 获取当前应用程序的绝对路径