[fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()

Fred van Stappen fiens at hotmail.com
Mon Jan 13 12:22:26 CET 2014


> Date: Mon, 13 Jan 2014 11:58:21 +0100
> From: michael at freepascal.org
> To: fpc-pascal at lists.freepascal.org
> Subject: Re: [fpc-pascal] windows.GetProcAddress() vs DynLibs.GetProcAddress()
> 
> 
> 
> On Mon, 13 Jan 2014, Fred van Stappen wrote:
> 
> > Hello.
> > 
> > I have a external dll. In Windows i can access perfectly the procedures with
> > GetProcAddress() if i use Windows unit.
> > 
> > If i use DynLibs unit, prog crash when i try to load the procedure.
> > I prefer to use DynLibs unit because i want to use the dll for Linux too (of course with library.so).
> > 
> > I have try, in linux to access the procedure with DynLibs too but same crash than for Windows.
> > What must i do to access procedure with DynLibs ?
> 
> Can you be more specific ?  What error do you get ? Can show some code ?
> 
> Michael.

Hello and many thanks for answer.

The library is SoundTouch.dll and libSoundTouch.so from :

>> http://www.surina.net/soundtouch/

>>>Here part of working code (if i call soundtouch_createInstance, it works)
...
uses   
Windows ;
...

var
soundtouch_createInstance : function() : THandle; stdcall;  

... 

procedure InitLib(LibFile : PAnsiChar);
begin
  LibHandle := LoadLibrary(LibFile);
  if LibHandle <> 0 then
     Pointer(soundtouch_createInstance)   := GetProcAddress(LibHandle, PAnsiChar('soundtouch_createInstance'));

/////////////////////

>>> Here part of NOT working code (if i call soundtouch_createInstance, it crash)
...
uses   
dynlibs ;
...

var
soundtouch_createInstance : function() : THandle; stdcall;  

... 

procedure InitLib(LibFile : PAnsiChar);

begin

LibHandle:=DynLibs.LoadLibrary(libfilename);
  if LibHandle <> DynLibs.NilHandle then
    
    Pointer(soundtouch_createInstance)        := DynLibs.GetProcedureAddress(LibHandle, PAnsiChar('soundtouch_createInstance')); 

/////////////////////

Many thanks.


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140113/d4b9cffd/attachment.html>


More information about the fpc-pascal mailing list