//取得程序运行的目录 m_strWorkDIR
TCHAR exeFullPath[_MAX_PATH];
char szDrive[_MAX_DRIVE]={0}, szDir[_MAX_DIR]={0}, szFNAME[_MAX_FNAME]={0}, szExt[_MAX_EXT]={0};
GetModuleFileName(AfxGetInstanceHandle(), exeFullPath, sizeof(exeFullPath));
_splitpath (exeFullPath, szDrive, szDir, NULL, NULL);
m_strWorkDIR.Format("%s%s", szDrive, szDir);
另附MSDN中的一段例码
Example
/* MAKEPATH.C */
#include <stdlib.h>
#include <stdio.h>
void main( void )
{
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_makepath( path_buffer, "c", "\\sample\\crt\\", "makepath", "c" );
printf( "Path created with _makepath: %s\n\n", path_buffer );
_splitpath( path_buffer, drive, dir, fname, ext );
printf( "Path extracted with _splitpath:\n" );
printf( " Drive: %s\n", drive );
printf( " Dir: %s\n", dir );
printf( " Filename: %s\n", fname );
printf( " Ext: %s\n", ext );
}
Output
Path created with _makepath: c:\sample\crt\makepath.c
Path extracted with _splitpath:
Drive: c:
Dir: \sample\crt\
Filename: makepath
Ext: .c
正文
取得程序运行的目录(ZT)2005-08-08 19:57:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/elva6401/3625.html
阅读(3169) | 评论(0)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论