Click to See Complete Forum and Search --> : Win32 API:please, help with .dll management
Philipp Skadorov
July 4th, 2001, 04:57 AM
When the .dll is loaded by some process, how can it get known from which directory it was loaded? I can not change the dll interface to implement the additional function for providing dll with its path. Maybe, it is possible to get the pass using dll HINSTANCE???
Thanks in advance!!!
Alex Fedotov
July 5th, 2001, 03:56 PM
Given DLL's HINSTANCE you can call GetModuleFileName to obtain the full
path to the DLL file:
TCHAR szPathName[MAX_PATH];
GetModuleFileName(hInstance, szPathName, MAX_PATH);
WillCodeForMoney
July 5th, 2001, 04:16 PM
As background information, there is an article in MSDN (you can search for it) that tells how Windows performs a search for a DLL to load.
If you want to know where a DLL is loaded from without running the software, you can run a utility call Dependency Walker on your program and it will list all the dependencies and where they are loaded from. Find the latest version of Dependency Walker at www.dependencywalker.com.
WillCodeForMoney
Philipp Skadorov
July 6th, 2001, 03:25 AM
Thanks for responce, I've alse first thought about using this function, but in MSDN:"The GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module." So, it returns the path to the executable that loaded the .dll
Alex Fedotov
July 6th, 2001, 02:32 PM
"Executable file" means either EXE or DLL. Both the main executable and
its DLLs become modules when loaded into the memory. GetModuleFileName
returns the name of the file from which a module was loaded. That means,
if you pass it HINSTANCE of a DLL, it will return the path to the DLL
file, not to the main EXE file.
Philipp Skadorov
July 9th, 2001, 03:48 AM
I've tried this function before asking for help at codeguru. You just read the appropriate MSDN section more carefully
Djibril
July 22nd, 2001, 11:22 AM
IMO there is no function call that gives a path to a dll.
--
Where there is a WISH, there is a WILL.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.