I've tried multiple snippets of code and multiple examples to try achieve this, but whenever I try them, I always get this error in iosfwd:
Exception thrown at 0x00161062 in app.exe: 0xC0000005: Access violation reading location 0x00000000.
Two pieces of code that don't work:
WCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
std::wcout << path;
HMODULE hModule = GetModuleHandleW(NULL);
WCHAR path[MAX_PATH];
GetModuleFileNameW(hModule, path, MAX_PATH);
How do I fix this? I need the full path of the executable in my application.
User contributions licensed under CC BY-SA 3.0