cpptrace/src/platform/libcpp_program_name.hpp
2023-07-01 17:06:41 -04:00

36 lines
602 B
C++

#ifndef LIBCPP_PROGRAM_NAME_HPP
#define LIBCPP_PROGRAM_NAME_HPP
#include <string>
#ifdef _WIN32
#include <windows.h>
namespace cpptrace {
namespace detail {
inline std::string program_name() {
char buffer[MAX_PATH + 1];
int res = GetModuleFileNameA(nullptr, buffer, MAX_PATH);
if(res) {
return buffer;
} else {
return "";
}
}
}
}
#else
namespace cpptrace {
namespace detail {
inline std::string program_name() {
return "";
}
}
}
#endif
#endif