Search code examples
c++dllwxwidgets

Get application path in dll


My host application was developed using wxWidgets and i need the app path in a pure C++ dll. If i'm developing a executable application i can get the application path from argv[0]. But, if i'm developing a dll how can i get the application path using just C++? Is it possible?


Solution

  • If you wish to obtain the application path in the host ( and pass it into the DLL code unsing a method ), then you can use the windows API GetModuleFileName() as suggested by other answerers. Alternatively, you might use the wxWidgets method wxStandardPaths::GetExecutablePath()