RES: Accessing C++ DLL function from Delphi

"Felipe Rezek Mohallem" <[email protected]>
Newsgroups gmane.comp.lang.delphi.programming
Message-ID <000201c34301$66d836e0$14fea8c0@MOHALLEM>
Why don't u try external calls?
Just like this:
 
function get_delay_time : integer; stdcall; external 'Module1.DLL';
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
begin
 showMessage ( intToSTr ( get_delay_time ) );
end;

[]s
Felipe
 
 -----Mensagem original-----
De: quadtech100 [mailto:[email protected]] 
Enviada em: sexta-feira, 4 de julho de 2003 20:04
Para: [email protected]
Assunto: [Delphi] Accessing C++ DLL function from Delphi



Hello -

I have been trying to access a function in a C++ DLL without 
success.  The function is given as:

int get_delay_time();

My current approach is as outlined below.  I get a "function not 
supported on this system" message at the LoadLibrary step, and "The 
specified module could not be found" message at the GetProcAddress 
step.

I seem to have this all fouled up.  Any suggestions would be most 
welcome.  Thanks.

-----------------------

var
  Form1: TForm1;
  DelayTime:  function (_get_delay_time:integer):integer cdecl;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
var
theHandle:THandle;
begin
theHandle:=LoadLibrary('Module1.DLL');
ShowMessage('LoadLibrary: '+SysErrorMessage(GetLastError));
if theHandle <> 0 then
  try
   @DelayTime:=GetProcAddress(theHandle,'get_delay_time');
   ShowMessage('GetProcAddress: '+SysErrorMessage(GetLastError))
  except
   ShowMessage('Error 0.  theHandle <> 0 ')
  end
else
  ShowMessage('Error 1.  theHandle=0 ');
end;





Yahoo! Groups Sponsor	

ADVERTISEMENT
 
<http://rd.yahoo.com/M=244522.3512152.4794593.1261774/D=egroupweb/S=1705
115362:HM/A=1595053/R=0/SIG=1245der9k/*http://ashnin.com/clk/muryutaitak
enattogyo?YH=3512152&yhad=1595053> Click Here!	
 
<http://us.adserver.yahoo.com/l?M=244522.3512152.4794593.1261774/D=egrou
pmail/S=:HM/A=1595053/rand=655251612> 	

Delphi Tips & Tutorials...
http://www.delphicollection.com
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
--------------------------------------------------------------- 

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> . 




[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Save up to 80% on top-quality inkjet cartridges and get your order fast!
FREE shipping on orders $50 or more to the US & Canada. Shop at Myinks.com!
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/v2G7ND/KfUGAA/ySSFAA/i7folB/TM
---------------------------------------------------------------------~->

Delphi Tips & Tutorials...
http://www.delphicollection.com
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
--------------------------------------------------------------- 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.