如果编写一个的exe可执行文件需要调用DLL文件,,如果通过VC运行这个程序,只要把DLL文件放在工程目录下就可以了,而不需要放到Debug或者Release目录下
   但是如果直接双击可执行文件运行,却会提示找不到DLL文件.
   按照装置DLL的说明,应不会到EXE所在目录的上层目录去找DLL文件,但是VC是如何实现让它能够去上层目录加载DLL的呢?

解决方案 »

  1.   

    工程目录即是VC的工作目录,当然能够找到。DLL查找的地方大概为:
    1、程序当前目录;
    2、系统目录;
    3、环境变量中指定的目录。最好是把DLL与EXE放在同一目录下。
      

  2.   

    但是EXE可执行文件跟DLL不在同一个目录啊,,所在你说的三个条件,他都没有满足,,
    我就是想知道,VC装载运行EXE是怎么样的一个过程,他是怎么在不满足这三个条件的情况下让它运行的
      

  3.   

    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. 
      

  4.   

    当你直接运行exe时一般当前目录(除非你更改)就是exe运行的目录
    而在vc下运行时当前目录应该是项目所在的目录
      

  5.   

    stonewater,你说得很对.
    刚才写了一个程序验证了一下,就是The directory from which the application loaded. 这一条起作用了
      

  6.   

    本目录、环境变量path指定的目录、vs的执行文件目录