Hi Vahan,
I also try that
But it is still not ok. Please help me. I have ever called c++ dll function
from delphi for long ago. it was ok.
But now, I can't. Please help me.
unit utestdll;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function fnDllsample(): integer; external 'dllsample.dll'
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
i := fnDllsample();
showmessage(inttostr(i));
end;
end.
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED]
Behalf Of Vahan Yoghoudjian
Sent: Wednesday, April 27, 2005 5:23 PM
To: [email protected]
Subject: RE: [delphi-en] How do I call a C++ DLL from Delphi
try the external directive, see Delphi help for more details
Vahan
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf
Of Tuan Le
Sent: Wednesday, April 27, 2005 11:14 AM
To: [email protected]
Cc: [EMAIL PROTECTED]
Subject: [delphi-en] How do I call a C++ DLL from Delphi
Hi all,
1. I have created a dll in Visual C by wizard
(File/New/Project/Win32 Dynamic-link Libary and select "A dll that exports
some symbols")
I built it and my dll is : dllsample.dll
In this dll, there is a sample function
DLLSAMPLE_API int fnDllsample(void)
{
return 42;
}
2. I also create a project in delphi. DllHandle is always not NULL but
@fnDllsample is null.
It seems fnDllsample does not export but I can call this function DLL in
visual c. Delphi can't
Please help me, how to call it.
Many thanks,
Tuan
(attached file : dllsample.zip)
-------------------------------------------
My code is below:
var
fnDllsample: function(): integer;
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
DLLHandle: THandle;
begin
DLLHandle := LoadLibrary('dllsample.dll');
if DLLHandle <> 0 then
begin
@fnDllsample := GetProcAddress(DLLHandle,'fnDllsample');
if @fnDllsample <> nil then
begin
i := fnDllsample;
showmessage(inttostr(i));
end;
end;
end;
end.
[Non-text portions of this message have been removed]
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
----------------------------------------------------------------------------
----
Yahoo! Groups Links
a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
b.. To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/