《VC++技术内幕》P430
    Windows将使用下面的搜索序列定为dll:
1、包涵EXE文件的目录
2、进程当前的目录
3、Windows系统目录
4、Windows目录
5、在Path环境变量里列出的目录。我的理解是如果程序文件在C:\code\run.exe
则 
1、包涵EXE文件的目录         C:\code\    
2、进程当前的目录            ?????
3、Windows系统目录           C:\windows\system32  还是C:\windows\system
4、Windows目录               C:\windows        
5、在Path环境变量里列出的目录。       ...........请问1、3、4我写的对吗,2怎么理解?C:\windows\system32和C:\windows\system中的dll文件有什么区别。我的系统是winxp

解决方案 »

  1.   

    1. yes
    2. 当前目录,可以用GetCurrentDirectory看看
    3. 系统目录在环境变量中有指定,是system32。可以用%system%引用环境变量得到
    4. 环境变量中也有指定,一般就是c:\windows或者c:\winnt
    5. 到命令行下,敲击path并回车命令可以看到path定义的路径;键入path=c:……可以设定路径
      

  2.   

    如果我拷贝一份到当前目录下,是否可以替换system32下的同名文件?
      

  3.   

    按照引用DLL的路径先后顺序引用DLL,所以你如果在当前目录下有一份DLL的话,是会替换System32下的同名DLL的.
      

  4.   

    正确,一般找dll,如果在可执行文件下面找到了dll就不会再到当前目录或者系统目录去找了!
      

  5.   

    3、Windows系统目录           C:\windows\system32  还是C:\windows\system

    是对不同系统说的,xp为system32,9x为system1、The directory from which the application loaded. 
    2、The current directory. 
    Windows XP: If HKLM\System\CurrentControlSet\Control\SessionManager\SafeDllSearchMode is 1, the current directory is the last directory searched. The default value is 0. 3、The Windows system directory. Use the GetSystemDirectory function to get the path of this directory. 
    Windows NT/2000/XP: The name of this directory is System32. Windows NT/2000/XP: The 16-bit Windows system directory. There is no function that obtains the path of this directory, but it is searched. The name of this directory is System. 
    4、The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 
    5、The directories that are listed in the PATH environment variable.