//获取当前运行的目录
char szPath[MAX_PATH]={0};
GetModuleFileName(NULL,szPath,MAX_PATH);
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath_s( szPath, drive,_MAX_DRIVE, dir,_MAX_DIR, fname,_MAX_FNAME, ext ,_MAX_EXT);
_makepath_s( g_szCurDir,MAX_PATH,drive,dir,NULL,NULL);
摘自MSDN,以备后用
char path_buffer[_MAX_PATH];
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
errno_t err;
err = _splitpath_s( FindFileData.cFileName, drive, _MAX_DRIVE, dir, _MAX_DIR, fname,
_MAX_FNAME, ext, _MAX_EXT );