Created
February 11, 2022 08:44
-
-
Save Zrufy/46aabef46cbd50191da5c9ef6e703317 to your computer and use it in GitHub Desktop.
C++ method to get the current directory, i.e. .EXE path.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <string> | |
std::string GetCurrentDirectory() | |
{ | |
char buffer[MAX_PATH]; | |
GetModuleFileNameA(NULL, buffer, MAX_PATH); | |
std::string::size_type pos = std::string(buffer).find_last_of("\\/"); | |
return std::string(buffer).substr(0, pos); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment