#include <iostream>
#include <string>
#ifdef WIN32
#define PATH_SEP "\\"
#else
#define PATH_SEP "/"
#endif
int test(int argc, char *argv[])
{
std::cout << argv[0] << std::endl;
std::string strProcName = argv[0];
std::string::size_type pos1 = strProcName.find_last_of(PATH_SEP);
if (pos1 != std::string::npos)
{
strProcName = strProcName.substr(pos1+1);
}
std::cout << strProcName << std::endl;
pos1 = strProcName.find(".exe");
if (std::string::npos != pos1)
{
strProcName = strProcName.substr(0, pos1);
}
std::cout << strProcName << std::endl;
return 0;
}
从argv中解析出进程名称
最新推荐文章于 2021-04-30 08:33:54 发布