• [手游项目5]windows获得当前进程名


    #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];
    }
  • 相关阅读:
    解决动态加载数据滑动失效
    js 判断手机横竖屏的实现方法(不依赖任何其他库)
    element-ui upload 图片格式验证 ,文件验证
    swiper 绑定点击事件 点击失效处理
    vue项目
    [Qt]自定义表头实现过滤功能
    字符串截取问题
    mysql超时机制
    nginx原理
    高可用集群(主从模式)
  • 原文地址:https://www.cnblogs.com/byfei/p/14104093.html
Copyright © 2020-2023  润新知