Lazarus
Installation => PDAs and Smartphones => Topic started by: JohnvdWaeter on February 07, 2008, 10:21:26 am
-
Hi all,
I use:
try
AHandle:=Loadlibrary(libname)
except
AHandle:=0
end;
In WM 5 and 6 I have no problem, because the library exists. In Windows Mobile 4 this library does not exist. Therefore I want to prevent errormessages by using Try/Except.
However, if I use an arbitrary name for the lib (that certainly does not exist), all WM4, 5 and 6 throw an exception that "some of the elements could not be found".
I hoped the try.. except.. construction would prevent such an error. Is there another way to check the existance of the library without throwing an error?
tia!
John
[/code]
-
LoadLibrary is a winapi function. Winapi functions never throw an exception.
According to MSDN:
Return values:
A handle to the module indicates success.
NULL indicates failure.
To get extended error information, call GetLastError.
So when AHandle = 0 then LoadLibrary failed. The MSDN doesn't meantion anything on showing dialogs.
The dialog you describe I only get when I statically reference to some library.
-
Hi Marc,
OK... I guess I'm missing the point where it comes to statically and dynamically referencing the library...
If I have a line in code that looks like:
function getMydata(...) external external_lib name GetMydata ;
that is a static reference, right?
Thanks for clarification!
John
-
Yes that is a static reference. These references are resolved by the windows image loader, the moment an executable image is loaded.