Конференция "KOL" » SafeLoadLibrary
 
  • Jon © (15.08.10 20:51) [0]
    In Err.pas there is SafeLoadLibrary


    { SafeLoadLibrary calls LoadLibrary, disabling normal Win32 error message
     popup dialogs if the requested file can't be loaded.  SafeLoadLibrary also
     preserves the current FPU control word (precision, exception masks) across
     the LoadLibrary call (in case the DLL you'
    re loading hammers the FPU control
     word in its initialization, as many MS DLLs do)}




    But when I try using it then I get a Win32 error message:


    program Test;

    uses Windows, KOL, err;

    var LibHandle: THandle;

    begin
     // The following file cannot be registered - Windows XP
     LibHandle := SafeLoadLibrary('c:\windows\system32\shell.dll');
     FreeLibrary(LibHandle);
    end.



    This is the message:


    ---------------------------
    Test.exe - Bad Image
    ---------------------------
    The application or DLL c:\windows\system32\shell.dll is not a valid Windows image. Please check this against your installation diskette.
    ---------------------------
    OK  
    ---------------------------



    Is there a bug in err.pas?
  • Vladimir Kladov © (15.08.10 21:34) [1]
    Did you try same code in VCL? You'll get the same message, I'm sure.
  • Jon © (15.08.10 22:46) [2]
    Probably, I shall check later, but why state in the documentation that SafeLoadLibrary disables the error message?
  • Jon © (16.08.10 00:50) [3]
    FYI, this works in both KOL and VCL:

    LibHandle := SafeLoadLibrary('c:\windows\system32\shell.dll',SEM_FAILCRITICALERRORS or SEM_NOOPENFILEERRORBOX);

Есть новые Нет новых   [134430   +4][b:0][p:0.001]