my app dynamically loads a dll. Inside the dll I need to know the HInstance of the dll module. But: the HInstance variable there is the one of the main app which loaded the dll.
There is one way I know of that works (stepping through the LibModuleList and checking the filename of the instances found there), but then I need to hard-code the dll's name. I want to avoid this.
So alternatively my question would be answered if I knew a generic way for a DLL to find out it's own filename.
Things I already tried but failed:
- put code in the initialization section of a unit of the dll to get the filename of the first module in the LibModuleList (which is the last one loaded), but it appears the dll has not yet been registered then.
- get the HInstance of the module that 'owns' a class or address defined or associated with a module in my dll. This also returns the HInstance of the main app.