Boost logo

Boost :

From: James Fowler (boost_list_at_[hidden])
Date: 2005-03-03 19:33:04


Jody Hagins wrote:

>Whenever I get a spare moment, I try to get my typeid/type_info tests
>working on windows (I am convinced that if I had started programming
>under that environment, I would have chosen a different line of work).
>Right now I am struggling a bit with the DLL library that is part of
>testing type_info. Everything works fine, except when it doesn't ;->
>
>The documentation of LoadLibrary() says it returns NULL on failure.
>However, I can feed it some files (like a valid .LIB that is not a DLL)
>and before LoadLibrary() returns, it displays a dialog box saying "Bad
>Image." I guess this could be an exception that BCB is intercepting and
>turning into a dialog box, but the docs say nothing about an exception.
>Also, I look on google, and find that people have similar problems from
>within Java (though I could not find any solutions).
>
>How do I prevent that from happening?
>
>
My guess is you may have to live with it, but... The MSDN page on
LoadLibrary
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp>
specifies that it expects the name of a .dll or .exe file. It might not
be very forgiving about anything else. However, the docs also mention a
function called SetErrorMode
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/seterrormode.asp>,
which can be used "to enable or disable error messages displayed by the
loader during DLL loads". Might do just what you're asking for, never
tried SetErrorMode myself (LoadLibrary however, still causes occasional
nightmares ;-) ).

Having said that, you might want to be aware that you may have quite a
bit of work beyond disabling this dialog box... the real problems start
when a call to LoadLibrary actually succeeds, but the dll you loaded
wasn't built quite the same way as the exe (or other dll) you're pulling
it into. I don't know if Boost has any magic pixie dust to catch this
(like the ABI hooks?) but LoadLibrary calls have been known to cause
quite a bit of grief when trying silly stuff like switching between
debug and release builds...

- james

>Thanks in advance!
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
>
>

-- 
__________________________________________________________
 James Fowler, Open Sea Consulting
 http://www.OpenSeaConsulting.com, Marietta, Georgia, USA
 Do C++ Right.  http://www.OpenCpp.org, opening soon!

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk