Click to See Complete Forum and Search --> : Where should the dll be put?


VicLin
April 13th, 2003, 03:51 AM
I build a dll of hook
but i discover that
I can put it at many dirs
and run it success

for a example...
my exe at
C:\abc\def\exe.exe

I can run it success when the dll at

C:\abc\hook.dll
C:\abc\def\hook.dll
C:\window\hook.dll

why?:confused: :confused: :confused:
my exe and dll at different dirs
why I can run it success?

there are so many dirs I can put and run success!!
than....where should i put the dll????:confused: :confused:

Bengi
April 13th, 2003, 04:11 AM
usually in the same dir or your exe ,
but most of them are in the windows\system32
or in the winnt\system32 :)

preetham
April 13th, 2003, 04:59 PM
i guess you can put it anywhere.
I put the one i am using in my folder and used regsvr32 to register the dll.
So i guess it depends on your dll and where u want to put it.

muthuis
April 14th, 2003, 01:01 AM
That depends on what kind of dll you are creating.
If I create a COM dll, then the registration is thru regsvr32. I can keep this dll anywhere in the machine.

If I have to create a win32 dll and use it via LoadLibrary method, regsvr32 is not necessary. In this case, if you don't specify a complete path, the program will try to search in the current path/windows/system32 etc.,

VicLin
April 14th, 2003, 06:34 AM
oh....
thank you a lot
now i know that why it can run success when the dll and prog at different dirs

Nati
April 15th, 2003, 09:25 PM
This is taken from MSDN

The Search Path Used by Windows to Locate a DLL
Home | Overview | How Do I | FAQ | Details | Sample

With both implicit and explicit linking, Windows first searches the set of pre-installed DLLs such as the performance library (KERNEL32.DLL) and the security library (USER32.DLL). Windows then searches for the DLLs in the following sequence:

The directory where the executable module for the current process is located.


The current directory.


The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.


The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.


The directories listed in the PATH environment variable.
Note that the LIBPATH environment variable is not used.