Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

A J Oja

Importing C++ DLL into Delphi

This topic is 6121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Since there is a way to load DLLs into Delphi dynamically... could someone help me with this: How to load a C++ DLL into Delphi... I tried with several different options but only got errors... Delphi geeks, here is your time to prove Delphi is better than this! - A.J. - "Where is the KABOOM?! There was supposed to be an earth-shattering KABOOM!"

Share this post


Link to post
Share on other sites
Advertisement
I''m a long time C/C++ coder... but my last contract was working on a Oracle/Delphi solution

Here is some code that I used to load and run a function from a DLL dynamically.


procedure TFrmMain.LoadAndRunDLLProcedure(sDLL, sFunc : string );
type
// define the type of "function"
// we''re calling
TFunc_Start = procedure;
var
Func_Start : TFunc_Start;

hDll : THandle;
FuncPtr : TFarProc;
sMsg : string;
begin
// Result := False;
hDll := LoadLibrary( PChar( sDLL ) );
if(hDll > 32)then
begin
FuncPtr := GetProcAddress( hDll, PChar( sFunc ) );
@Func_Start := FuncPtr;
if(nil <> @Func_Start)then
begin
Func_Start;
//Result := True;
end else
begin
sMsg := ''DLL entry point '' + sFunc + '' not found'';
MessageBox( 0, PChar( sMsg ), ''Error'', MB_OK );
end;
FreeLibrary( hDll );
end else
begin
sMsg := ''File '' + sDLL + '' not found'';
MessageBox( 0, PChar( sMsg ), ''Error'', MB_OK );
end;

// MessageBox( 0, PChar( ''Bottom of LoadAndRunDLLProcedure'' ), ''Error'', MB_OK );

end;


You will most definately need to modify the code to work with functions that take params and this is just for functions not classes or functions within classes.




Dak Lozar
Elysian Productions, Inc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!