在程序中自动获取exe执行文件名字

    xiaoxiao2025-08-03  15

    全局变量: std::string ServerName; // 服务名称(程序本身名字) int main()内: char filepath[1024] = ""; //获取exe执行文件名字(去掉后缀".exe") GetModuleFileName(NULL, filepath, MAX_PATH); *strrchr(filepath,'.') = '\0';   // 从最左边开始最后一次出现"."的位置(注:strchr/strrchr函数使用) ServerName = strrchr(filepath, '\\') + 1;
    转载请注明原文地址: https://ju.6miu.com/read-1301355.html
    最新回复(0)