Hi, In you c++ code you need to specify to export the function, something like extern "C" __declspec (dllexport) int fnDllsample ( void ) You can always use tdump ( found in the bin-dir of delphi ) to check which functions are exported within you dll Regards, Peter
-----Oorspronkelijk bericht----- Van: Tuan Le [mailto:[EMAIL PROTECTED] Verzonden: woensdag 27 april 2005 11:14 Aan: [email protected] CC: [EMAIL PROTECTED] Onderwerp: [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/ <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/ <http://groups.yahoo.com/group/delphi-en/> * To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . _____________________________________________________________________ For Your safety, Aucxis Trading Solutions scanned this e-mail for viruses, using MCI's Internet Managed Scanning Services, powered by MessageLabs. For further information visit http://www.mci.com _____________________________________________________________________ For Your safety, Aucxis Trading Solutions scanned this e-mail for viruses, using MCI's Internet Managed Scanning Services, powered by MessageLabs. For further information visit http://www.mci.com [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/

