获取exedll路径

mac2024-04-13  44

#include "stdafx.h" #include <string> #include <Windows.h>   #include <iostream>    using namespace std; string GetProgramDir()   {        char exeFullPath[MAX_PATH]; // Full path     string strPath = "";

    GetModuleFileName(NULL,exeFullPath,MAX_PATH);     strPath=(string)exeFullPath;    // Get full path of the file     int pos = strPath.find_last_of('\\', strPath.length());     return strPath.substr(0, pos);  // Return the directory without the file name }    int _tmain(int argc, _TCHAR* argv[]) {     string str = "";

    str = GetProgramDir();     cout << str << endl;

    system("pause");

    return 0; }  

最新回复(0)