<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3086" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hello,</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>How old is snapshot you are using?</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Yury Sidorov.</FONT></DIV>
<DIV> </DIV>
<DIV style="FONT: 10pt arial">----- Original Message -----
<DIV style="BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> <A
title=mark@wbisoft.com href="mailto:mark@wbisoft.com">Mark - WBIsoft.COM</A>
</DIV>
<DIV><B>To:</B> <A title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">fpc-devel@lists.freepascal.org</A>
</DIV>
<DIV><B>Sent:</B> Saturday, July 07, 2007 11:51 AM</DIV>
<DIV><B>Subject:</B> [fpc-devel] LoadLibrary fails if called from a
DLL</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Hi, </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV>I'm having a strange issue with the LoadLibrary call in the 64bit beta
version of the free pascal compiler (fpc 2.1.5 with lazarus 0.9.23 beta) -
standard install from the sourceforge download and installed in the default
c:\lazarus directory.</DIV>
<DIV> </DIV>
<DIV>I have written a function in FPC that I have used in Delphi for many many
years with out problem. Ok, here's a simple piece of code</DIV>
<DIV> </DIV>
<DIV>function myfunction(a, var b : dword) : boolean;</DIV>
<DIV>var dllh : cardinal;</DIV>
<DIV> fun : function (a : dword; var b : dword) :
boolean; stdcall;</DIV>
<DIV>begin</DIV>
<DIV> result := false;</DIV>
<DIV> </DIV>
<DIV> dllh := loadlibrary('c:\windows\system32\somelib.dll');</DIV>
<DIV> if dllh <> 0 then</DIV>
<DIV> begin</DIV>
<DIV> fun := nil;</DIV>
<DIV> fun :=
getprocaddress(dllh,'someproc');</DIV>
<DIV> if fun <> nil then result :=
fun(a,b);</DIV>
<DIV> end</DIV>
<DIV> else</DIV>
<DIV> result := false;</DIV>
<DIV>end;</DIV>
<DIV> </DIV>
<DIV>Now here's my problem - very simply if I compile this into a standard
console application it works fine, however, if I compile it into the DLL I am
planing to run it in it fails - the loadlibrary call ALWAYS returns 0x7C370000
which appears to be a memory address rather than a handle - the result is that
the getprocaddress returns an invalid address and fails.</DIV>
<DIV> </DIV>
<DIV>So, why is the loadlibrary call failing (or returning this memory address)
when in a DLL but NOT when it's in a console app.</DIV>
<DIV> </DIV>
<DIV>Any help would be great, as I cannot seem to find an implementation of
GETLASTERROR to pass to SYSERRORMESSAGE to display any error from the OS if
there is one !</DIV>
<DIV> </DIV>
<DIV>Thanks folks</DIV>
<DIV> </DIV>
<DIV>Mark</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><BR>Kind regards</DIV>
<DIV> </DIV>
<DIV>Mark Cook<BR>WBIsoft.COM</DIV>
<DIV> </DIV>
<DIV><BR>Any opinions expressed in this message are those of the individual and
not necessarily the company. This message and any files transmitted with it are
confidential and solely for the use of the intended recipient. If you are not
the intended recipient or the person responsible for delivering to the intended
recipient, be advised that you have received this message in error and that any
use is strictly prohibited. </DIV>
<DIV> </DIV>
<DIV>This email was scanned for viruses when sent, however we advise you to
carry out your own virus check before opening any attachment(s) as we cannot
accept liability for any damage sustained as a result of any software
viruses.</FONT></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR></BODY></HTML>