How can I inside a library determine the location of the library on the harddisk?
Using below code determines the application path which in this case is not related to the library path.
QString path = QCoreApplication::applicationDirPath();
Using Windows XP SP3 and Qt 4.7.1.
i'm usyng in main.cpp:
QString env = getenv("SYSTEMROOT");
Thanks for the reply but not exactly what I need.
Say I develop a library and install it on a WinXP computer at a location unknown to the library itself. The location of the library can be anywhere or the harddisk.
Say an application then loads the library into its memory.
Inside the library, in the constructor of the class MySuperClass I would like to determine the location of the library. How can I do that?
There is no correlation between the location of the application and library.
If you do not know where is the thing you're looking for it. You can recursive/iterating search for your dll on all hard disk.
But I think better put dll where you know.
Thanks for the reply.
Searching for the library could be an option but is time consuming and could return wrong path if multiple files exist with same name.
If you need not crossplatform solution u can:
//add to header file
extern "C" IMAGE_DOS_HEADER __ImageBase;
#define THIS_MODULE_HINSTANCE reinterpret_cast<HINSTANCE>(&__ImageBase)