您的位置:程序门 -> vc/mfc -> 进程/线程/dll



请教 : 一程序在load dll 的时候,是从什么路径开是读的?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请教 : 一程序在load dll 的时候,是从什么路径开是读的?
发表于:2007-04-04 17:31:25 楼主
请教   :   一程序在load   dll   的时候,是从什么路径开是读的?
发表于:2007-04-04 17:40:121楼 得分:0
dynamic-link   library   search   order
starting   with   windows   xp,   the   dynamic-link   library   (dll)   search   order   used   by   the   system   depends   on   the   setting   of   the   hklm\system\currentcontrolset\control\session   manager\safedllsearchmode   value.


windows   server   2003:     the   default   value   is   1.
windows   xp:     the   default   value   is   0.
if   safedllsearchmode   is   1,   the   search   order   is   as   follows:

the   directory   from   which   the   application   loaded.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   16-bit   system   directory.   there   is   no   function   that   obtains   the   path   of   this   directory,   but   it   is   searched.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   current   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.  
if   safedllsearchmode   is   0,   the   search   order   is   as   follows:

the   directory   from   which   the   application   loaded.  
the   current   directory.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   16-bit   system   directory.   there   is   no   function   that   obtains   the   path   of   this   directory,   but   it   is   searched.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.  

alternate   search   order

the   loadlibraryex   function   supports   an   alternate   search   order   if   the   call   specifies   load_with_altered_search_path   and   the   lpfilename   parameter   specifies   a   path.   if   safedllsearchmode   is   1,   the   alternate   search   order   is   as   follows:

the   directory   specified   by   lpfilename.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   16-bit   system   directory.   there   is   no   function   that   obtains   the   path   of   this   directory,   but   it   is   searched.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   current   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.  
if   safedllsearchmode   is   0,   the   alternate   search   order   is   as   follows:  
the   directory   specified   by   lpfilename.  
the   current   directory.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   16-bit   system   directory.   there   is   no   function   that   obtains   the   path   of   this   directory,   but   it   is   searched.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.  
note   that   the   standard   search   strategy   and   the   alternate   search   strategy   differ   in   just   one   way:   the   standard   search   begins   in   the   calling   application 's   directory,   and   the   alternate   search   begins   in   the   directory   of   the   EXECutable   module   that   loadlibraryex   is   loading.

if   you   specify   the   alternate   search   strategy,   its   behavior   continues   until   all   associated   EXECutable   modules   have   been   located.   after   the   system   starts   processing   dll   initialization   routines,   the   system   reverts   to   the   standard   search   strategy.


legacy   search   order

earlier   versions   of   windows   do   not   support   the   safedllsearchmode   value.   the   dll   search   order   is   as   follows.

windows   2000/nt:     the   system   searches   for   dlls   in   the   following   order:
the   directory   from   which   the   application   loaded.  
the   current   directory.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   16-bit   system   directory.   there   is   no   function   that   obtains   the   path   of   this   directory,   but   it   is   searched.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.  
windows   me/98/95:     the   system   searches   for   dlls   in   the   following   order:
the   directory   from   which   the   application   loaded.  
the   current   directory.  
the   system   directory.   use   the   getsystemdirectory   function   to   get   the   path   of   this   directory.  
the   windows   directory.   use   the   getwindowsdirectory   function   to   get   the   path   of   this   directory.  
the   directories   that   are   listed   in   the   path   environment   variable.
发表于:2007-04-04 17:41:342楼 得分:0
http://msdn2.microsoft.com/en-us/library/ms682586.aspx


快速检索

最新资讯
热门点击