LoadLibrary("c:\\mydll.dll"),在WIN2000下发现如果把一个不是DLL的文件,如文本文件改名为"mydll.dll",系统会弹出一个框提示:“ - 损坏的图像: 应用程序或 DLL C:\mydll.dll 为无效的 Windows 映像。请再检测一遍您的安装盘。”,并且记录到系统日志。
我不想让这个框弹出来该怎么办呢?我编译的已经是release版本了,用try catch不到。

解决方案 »

  1.   

    HINSTANCE h=LoadLibrary("aaa.dll");
    如果dll不对,h就是NULL
      

  2.   

    你虽然把文件名称改成.dll了,但是其内部结构还
    是文本文件的结构当然出错了,就像楼上说的LoadLibrary返回
    的句柄是个NULL。
    你用的try catch是什么样的,是不是捕获所有的异常!

    try{
    .....
    }
    catch(...){
    .......
    }
    是捕获所有的异常! 在不知道异常的类型的时候用这个比较方便祝你成功!
    呵呵……
      

  3.   

    The SetErrorMode function controls whether the system will handle the specified types of serious errors, or whether the process will handle them.
    UINT SetErrorMode(
      UINT uMode
    );
      

  4.   

    Parameters
    uMode 
    [in] Specifies the process error mode. This parameter can be one or more of the following values. Value Action 
    0 Use the system default, which is to display all error dialog boxes. 
    SEM_FAILCRITICALERRORS The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. 
    SEM_NOALIGNMENTFAULTEXCEPT 64-bit Windows: The system automatically fixes memory alignment faults and makes them invisible to the application. It does this for the calling process and any descendant processes. 
    After this value is set for a process, subsequent attempts to clear the value are ignored.
     
    SEM_NOGPFAULTERRORBOX The system does not display the general-protection-fault message box. This flag should only be set by debugging applications that handle general protection (GP) faults themselves with an exception handler. 
    SEM_NOOPENFILEERRORBOX The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process. 
    Return Values
    The return value is the previous state of the error-mode bit flags. 
      

  5.   

    SetErrorMode,原来如此,谢谢。