I Vahan, I can call your MessageBox function. --> It seem that my c++ dll have problem --> delphi can not see the exported c++ function. Please help me the reason why.
Thanks, Tuan -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of Vahan Yoghoudjian Sent: Wednesday, April 27, 2005 5:50 PM To: [email protected] Subject: RE: [delphi-en] How do I call a C++ DLL from Delphi Hi Tuan To tell you the truth I've never used dll written in C++, all the dll I've used were written in Delphi, now that I read the help file more I noticed that calling directives are used also while declaring the function for example: function MessageBox(HWnd: Integer; Text, Caption: PChar; Flags: Integer): Integer; stdcall; external 'user32.dll' name 'MessageBoxA'; In Delphi 6 help under 'external declarations' there's a quite detailled help about this How is it not working, giving an exception, an error message, wrong return value...? Vahan -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of Tuan Le Sent: Wednesday, April 27, 2005 11:39 AM To: [email protected] Subject: RE: [delphi-en] How do I call a C++ DLL from Delphi 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 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/

