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

<*> 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/
 



Reply via email to