miwaiwai

导航

c&c++ 的window环境获取exe文件所在的目录


#include <iostream>
#include<stdio.h>
#include <direct.h>
#include <windows.h>
#include<process.h>
#include <atlstr.h>

char
buff[MAX_PATH];//用于存放获取的路径信息。 GetModuleFileName(NULL, buff, MAX_PATH); CString str2 = buff; int pos = str2.ReverseFind('\\');//查找倒数最后一个“\\”符号 str2 = str2.Left(pos + 1); //删除最后一个\后面的字符 cout << str2 << endl;

 

posted on 2023-04-19 11:16  米歪歪  阅读(158)  评论(0编辑  收藏  举报