#include "stdafx.h"
#include <windows.h>
int main(int argc, char* argv[])
{//先获取运行程序的完整路径
char szFileName[256];
memset(szFileName,'"0',sizeof(szFileName));
GetModuleFileName(NULL,szFileName, sizeof(szFileName));
//再分割完整路径的字符串,最后一个就是程序的名字
char *token = NULL;
char exeName[256];
memset(exeName,'\0',sizeof(exeName));
token = strtok( szFileName, seps );
while( token != NULL )
{
sprintf(exeName,"%s",token);
token = strtok( NULL, seps );
}
printf("%s\n",exeName);
getchar();
return 0;
}