#include <windows.h>
#include <stdio.h>
#include <string>
using namespace std;
void SplitString2Int(const string& src, string delimit, vector<string>& vecRet)
{
string null_subst = "0";
if (src.empty() || src == "" || delimit.empty() || delimit == "")
return;
int deli_len = delimit.size();
int nIndex = 0;
int last_search_position = 0;
while ((nIndex = src.find(delimit, last_search_position)) != -1)
{
if (nIndex == last_search_position)
{
string nValue = null_subst.c_str();
vecRet.push_back(nValue);
}
else
{
string nValue = src.substr(last_search_position, nIndex - last_search_position).c_str();
vecRet.push_back(nValue);
}
last_search_position = nIndex + deli_len;
}
string last_one = src.substr(last_search_position);
if (last_one.empty())
{
string nValue = (null_subst.c_str());
vecRet.push_back(nValue);
}
else
{
string nValue = (last_one.c_str());
vecRet.push_back(nValue);
}
}
std::string TCHAR2STRING(TCHAR *STR)
{
int iLen = WideCharToMultiByte(CP_ACP, 0, STR, -1, NULL, 0, NULL, NULL);
char* chRtn = new char[iLen * sizeof(char)];
WideCharToMultiByte(CP_ACP, 0, STR, -1, chRtn, iLen, NULL, NULL);
std::string str(chRtn);
delete chRtn;
return str;
}
void main()
{
TCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
vector<string> FileName;
string strPath = TCHAR2STRING(szPath);
SplitString2Int(strPath,"\", FileName);
string strFileName = FileName[FileName.size() - 1];
}