GetModuleHandle Problem
-
Hi, every one, I got a problem when using the
::GetModuleHandle
API, it always fails if I pass in an absolute path, for example,::GetModuleHandle("c:\\my app\\app.dll");
will fail even though the file "c:\\my app\\app.dll" exists, but if I copy the program into that directory and call::GetModuleHandle("app");
it succeeds. Why can't I use an absolute path for the module? Thank you. -
Hi, every one, I got a problem when using the
::GetModuleHandle
API, it always fails if I pass in an absolute path, for example,::GetModuleHandle("c:\\my app\\app.dll");
will fail even though the file "c:\\my app\\app.dll" exists, but if I copy the program into that directory and call::GetModuleHandle("app");
it succeeds. Why can't I use an absolute path for the module? Thank you.A suspicion I have is that perhaps the module is in several places on your machine. The one your process is loading is probably not the full path you are testing. You can try this topic from MSDN: "Enumerating All Modules For a Process" to determine if the module you are loading is actually from the path you suspect. If it is not indeed loaded from that specific path, then the function call will fail.