From: benl@panix.com Subject: Re: [delphi] explicit DLL linking Date: Tue, 27 Jun 1995 04:31:17 -0400 <---- Begin Included Message ----> I need help using LoadLibrary and GetProcAddress to call a DLL function. I get LoadLibrary and GetProcAddress to work fine, but how do I call the function once I have its pointer? <---- End Included Message ----> I have dealt with this very problem so I know the answer (YEAH!!!). Lets take a hypothetical case that you are calling the following function: function myfunc(aparam : word) : string; export; okay. you need to make a type statement: type Tmyfunc = function(aparam : word) : string; You've done this already: var aptr, bptr : TFarProc; lhnd : THandle; s : string; begin lhnd := loadlibrary('c:\mypath\mylib.dll'); aptr := getprocaddress('myfunc', lhnd); {you need to add the next statement} bptr := makeprocinstance(aptr, lhnd); {now if you want to call it, just type cast it} s := Tmyfunc(bptr)(60); end; Hope this helps, Ben ------------------------------------------------------------------------------- From: Robert Subject: Re: [delphi] explicit DLL linking Date: Tue, 27 Jun 95 10:00:25 WET DST >>>> I need help using LoadLibrary and GetProcAddress to call a DLL function. I get LoadLibrary and GetProcAddress to work fine, but how do I call the function once I have its pointer? >>>> Try this: type TYourDllFunction = function():; var YourDllFunction: TYourDllFunction; begin Library := LoadLibrary(''); if Library > HINSTANCE_ERROR then begin @YourDllFunction := GetProcAddress(Library, 'YourDLLFunction'); end; {from now on you can just call your DLL function} YourDllFunction(); end; ------------------------------------------------------------------------------- From: grayzman@Academic.COM (Gregory Rayzman) Subject: Re: [delphi] explicit DLL linking Date: Tue, 27 Jun 95 10:35:06 PDT >>I need help using LoadLibrary and GetProcAddress to call a DLL function. I >>get LoadLibrary and GetProcAddress to work fine, but how do I call the >>function once I have its pointer? >> >> >> Here is an example type TGetGlobalStr = function( S: PChar) : PChar; var func : TFarProc; begin libraryHadle := LoadLibrary('get_glob.dll'); { Convert from Pascal to C null-string} StrPCopy( variableName, varName); func := GetProcAddress(libraryHadle, 'GetGlobal'); ff := TGetGlobalStr (func)( variableName); end. Gregory. -Gregory grayzman@academic.com