const char* getModuleFileName()
{
static char Result[256]="";
if( !Result[0] )
{
char Tmp[256], *End=Tmp;
GetModuleFileName( NULL, Tmp, ARR_COUNT(Tmp) );//returns the path for the file used to create the calling process.
while( strchr(End,'//') )
End = strchr(End,'//')+1;
while( strchr(End,'/') )
End = strchr(End,'/')+1;
if( strchr(End,'.') )
*strchr(End,'.') = 0;
CStr::strcpy( Result, End );
}
return Result;
}
strchr 使用例子
最新推荐文章于 2025-08-22 22:21:09 发布
本文介绍了一个C/C++函数,用于获取当前调用进程的文件名。通过使用`GetModuleFileName` API,该函数能够返回执行文件的路径,并从中提取出文件的基本名称。

2330

被折叠的 条评论
为什么被折叠?



