怎么得到当前应用程序的路径呢?
解决方案 »
- UTC时间转换
- 经验分享,或许大家都知道,但是没人注意的小问题.......
- bt用的ptop通讯是建立在socket上的么,
- LayeredWindow 有关透明窗体的创建问题,请高手指教
- 自己关闭一个对话框要执行哪些函数?
- 高手看题: 绝对界面问题!
- 请教高手,如何过滤消息?
- 这儿人多,我问问这里!我的IIS问题,别的计算机访问网站,老是要网络密码!
- 有些问题怎么想也不明白!(在线等待,即时结算)
- DirectSound,读取Wav资源
- 如何给CFileDialog打开或者保存指定路径,打开或者保存完毕后,如何恢复原有路径?
- 在编一个基于C/S结构的聊天程序,Client与Server的端口号必须相同吗,可不可以不相同?QQ的Client、Server的端口设得是多少?
{
/*++
// 函数名:GetWorkPath// 编写者:times// 参考资料:Windows system // 创建时间:2002.07.11// 修改时间:// 功 能:得到应用程序的当前目录// 输入参数:// 输出参数:// 返回值:返回字符串,当前目录// 备 注:--*/
char FilePath[500];
int PathLen =::GetModuleFileName(NULL,FilePath,5000);
while(TRUE)
{
if (FilePath[PathLen--]=='\\')
break;
}
FilePath[PathLen+2] = 0x0;
CString PathName = FilePath;
return PathName;
}
DWORD nBufferLength, // size of directory buffer
LPTSTR lpBuffer // directory buffer
);
CString Memo;
getCurrentDirectory(MAX_PATH,Memo);
getcurrentdirectory
getmodulefilenameunix:
getcwdtc:
int getcurdir(int drive,char *direc)
此函数返回指定驱动器的当前工作目录名称。成功返回0
drive 指定的驱动器(0=当前,1=A,2=B,3=C等)
direc 保存指定驱动器当前工作路径的变量
HMODULE hModule, // handle to module
LPTSTR lpFilename, // file name of module
DWORD nSize // size of buffer
);
/* This program places the name of the current directory in the
* buffer array, then displays the name of the current directory
* on the screen. Specifying a length of _MAX_PATH leaves room
* for the longest legal path name.
*/#include <direct.h>
#include <stdlib.h>
#include <stdio.h>void main( void )
{
char buffer[_MAX_PATH]; /* Get the current working directory: */
if( _getcwd( buffer, _MAX_PATH ) == NULL )
perror( "_getcwd error" );
else
printf( "%s\n", buffer );
}
CString CDlg::GetAppPath()
{
char PathName[255];
GetModuleFileName(AfxGetInstanceHandle(), PathName,sizeof( PathName ) );
char *a,*b;
a = b = PathName;
while(b)
{
b=strchr(a+1,'\\');
if(b) a=b;
}
*a='\0';
return PathName;
}