<!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.3132" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Yury,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>have now recompiled the DLL with the latest SVN
build using the 2_2 fixes but get the same problem, load library returns the
same hex value 0x7c37000 - the actual procedure I have in the DLL is as
follows</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Courier size=1>// ------------ cut code here</FONT></DIV>
<DIV><FONT face=Courier size=1></FONT> </DIV>
<DIV><FONT face=Courier size=1>function GetModuleHandle(lpModuleName: PCHAR):
cardinal; stdcall; external 'kernel32.dll' name 'GetModuleHandleA';<BR>function
LoadLibrary(lpLibFileName: PCHAR): cardinal; stdcall; external 'kernel32.dll'
name 'LoadLibraryA';<BR>function GetProcAddress(hModule: HMODULE; lpProcName:
LPCSTR): FARPROC; stdcall; external 'kernel32.dll' name
'GetProcAddress';</FONT></DIV>
<DIV><FONT face=Courier size=1></FONT> </DIV><FONT face=Arial size=2>
<DIV><FONT face=Courier size=1>procedure debug(fn, tx : string);<BR>var f :
textfile;<BR>begin<BR>
assignfile(f,'c:\skelgina.log');<BR> if
fileexists('c:\skelgina.log') then<BR>
append(f)<BR> else<BR>
rewrite(f);<BR> writeln (f,timetostr(now) + ' - ' + fn +
': ' + tx);<BR> writeln (f);<BR>
closefile(f);<BR>end;</FONT></DIV>
<DIV><FONT face=Courier size=1></FONT> </DIV>
<DIV><FONT face=Courier size=1>procedure GetProcedureAddress(var P: Pointer;
const ModuleName, ProcName: string); stdcall;<BR>var<BR> ModuleHandle:
cardinal;<BR>begin<BR> debug('GetProcedureAddress','Called');<BR>
debug('GetProcedureAddress','ModuleName: '+modulename);<BR>
debug('GetProcedureAddress','ProcName: '+procname);</FONT></DIV>
<DIV><FONT face=Courier size=1></FONT> </DIV>
<DIV><FONT face=Courier size=1> <BR> if not Assigned(P)
then<BR> begin<BR> debug('GetProcedureAddress','P is not
assigned');<BR> begin<BR>
ModuleHandle := SafeLoadLibrary('MSGINA.DLL');<BR>
debug('GetProcedureAddress','LoadLibrary MSGINA.DLL returns
$'+inttohex(ModuleHandle,16));<BR> end;<BR>
P := Pointer(GetProcAddress(ModuleHandle,
PChar(ProcName)));<BR> <BR> end<BR>
else<BR> debug('GetProcedureAddress','P is already
assigned');<BR> <BR> debug('GetProcedureAddress','Exits - P assigned
'+booltostr(assigned(p)));<BR>end;<BR></FONT></DIV>
<DIV><FONT face=Courier size=1>
<DIV><FONT face=Courier size=1>// ------------ end code here</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></DIV></FONT>
<DIV>Any thoughts on this ? I pulled the GetProcedureAddress function from
the Jwa??? components to test incase it was my implementation of the LoadLIbrary
code in FPC but obviously it's not !!!</DIV>
<DIV> </DIV>
<DIV>Cheers</DIV>
<DIV> </DIV>
<DIV>Mark</DIV>
<DIV> </DIV>
<DIV> </DIV></FONT>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jura@cp-lab.com href="mailto:jura@cp-lab.com">Yury Sidorov</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">FPC developers' list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, July 08, 2007 6:24 PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [fpc-devel] LoadLibrary
fails if called from a DLL</DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR></DIV>
<DIV><FONT size=2>Go to sources folder and execute:</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>make distclean<BR>make all<BR>make install SNAPSHOT=1
INSTALL_PREFIX=C:/some_folder</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Yury.</DIV>
<DIV><BR></DIV></FONT>
<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 developers' list</A> </DIV>
<DIV><B>Sent:</B> Sunday, July 08, 2007 8:15 PM</DIV>
<DIV><B>Subject:</B> Re: [fpc-devel] LoadLibrary fails if called from a
DLL</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>THanks, one final (i hope) question </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I assume I need to grab the entire folder and
recompile it - if so I assume I can compile with FPC itself ????</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Mark</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jura@cp-lab.com href="mailto:jura@cp-lab.com">Yury Sidorov</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">FPC developers' list</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, July 08, 2007 6:12
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [fpc-devel] LoadLibrary
fails if called from a DLL</DIV>
<DIV><BR></DIV>
<DIV><FONT size=2>Get sources from svn using this path:</FONT></DIV>
<DIV><FONT size=2><A
href="http://svn.freepascal.org/svn/fpc/branches/fixes_2_2">http://svn.freepascal.org/svn/fpc/branches/fixes_2_2</A></FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>I dont know where snapshots can be found.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Yury.</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 developers' list</A> </DIV>
<DIV><B>Sent:</B> Sunday, July 08, 2007 8:06 PM</DIV>
<DIV><B>Subject:</B> Re: [fpc-devel] LoadLibrary fails if called from a
DLL</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>can you suggest the best way (ie. the correct
url) for me to run with the svn.exe command to get the latest snapshot as
I'm unsure where the x86_64 stuff is - esp as it would appear to have
vanished from the sourceforge page ?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>What's the current x86_64 snapshot version
?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Mark</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jura@cp-lab.com href="mailto:jura@cp-lab.com">Yury Sidorov</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">FPC developers' list</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, July 08, 2007 6:05
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [fpc-devel] LoadLibrary
fails if called from a DLL</DIV>
<DIV><BR></DIV>
<DIV><FONT size=2>Hi,</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>I fixed DLL related a few weeks ago. You need to get
more fresh snapshot and test it.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>Yury.</FONT></DIV>
<DIV><FONT size=2></FONT> </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 developers' list</A>
</DIV>
<DIV><B>Sent:</B> Sunday, July 08, 2007 7:59 PM</DIV>
<DIV><B>Subject:</B> Re: [fpc-devel] LoadLibrary fails if called from a
DLL</DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=Arial size=2>Hi Yury,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>specifically the file was
lazarus-0.9.23-fpc-2.1.5-20070531-win64.exe </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Hope this helps ?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Mark</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=jura@cp-lab.com href="mailto:jura@cp-lab.com">Yury Sidorov</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fpc-devel@lists.freepascal.org
href="mailto:fpc-devel@lists.freepascal.org">FPC developers' list</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, July 08, 2007 5:28
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [fpc-devel]
LoadLibrary fails if called from a DLL</DIV>
<DIV><BR></DIV>
<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>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition. <BR>Version: 7.5.476 / Virus Database: 269.10.2/890 - Release
Date: 07/07/2007 15:26<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition. <BR>Version: 7.5.476 / Virus Database: 269.10.2/890 - Release
Date: 07/07/2007 15:26<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition. <BR>Version: 7.5.476 / Virus Database: 269.10.2/890 - Release Date:
07/07/2007 15:26<BR></BLOCKQUOTE>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>_______________________________________________<BR>fpc-devel
maillist -
fpc-devel@lists.freepascal.org<BR>http://lists.freepascal.org/mailman/listinfo/fpc-devel<BR>
<P>
<HR>
<P></P>No virus found in this incoming message.<BR>Checked by AVG Free
Edition. <BR>Version: 7.5.476 / Virus Database: 269.10.2/890 - Release Date:
07/07/2007 15:26<BR></BLOCKQUOTE></BODY></HTML>