How do I import a Delphi DLL into VC++

Started by
3 comments, last by Biberpelztrompete 22 years, 10 months ago
Hiya, does anyone how to import a DLL in BUILD-TIME in MS Visual C++. I know the LoadLibrary(xy) bla bla method but isnt there a simpler way to do this ?? Thanx
Advertisement
It doesnt make a difference how the dll was made. I have used dlls made by delphi and they were pretty simple. I just followed what the msdn said about using dlls, and they worked perfectly. So just look up dll''s in the msdn.

Possibility
Hm,
thanks..
I looked it up and it says I would need a .lib File to be able to link the DLL correctly. But how do I get a .lib file ??
So you see I''m absolute beginner in VC++.
Thanx anyway
Hi Biberpelztrompete,

quote:Original post by Biberpelztrompete

"Hm,
thanks..
I looked it up and it says I would need a .lib File to be able to link the DLL correctly. But how do I get a .lib file ??"

This .lib file is nothing but some sort of header information that is used by your compiler. The compiler sees what functions are in the according lib and what formal parameters they have and their relatibve entry point in the lib. The effect is that the compiler will not complain that he cannot find the binary code for these functions during linking since the real linking is done at runtime. There are many ways to include
such a lib during runtime. The best would be to write a C++ header that declares these functions as import/export functions.
Another way is to use a so called .def file where you have chapters for all imported and exported functions in your VC project. A third way is to use a utility that creates such an import file (.lib) from an existing dll. Such a utility came with the old Borland C++ compilers but i do not know if this is also true for VC.
To do it completely flexible i would use the header approach and use LoadLibrary() and GetProcAddress(). Then you can define an abstract interface for your dll''s for example and load these kind of dll''s during runtime.

So you see I''m absolute beginner in VC++.
Don''t worry, this is then the right place for you.


PS:
Biberpelz and Trompete sounds pretty german ????

cu

Peter
HPH
Hi,
uumm the first way sounds to me to be the simplest. I know how to write a .h file but how do I declare functions as import functions ? And how to declare in which DLL they can be found.
I don''t want to load the DLL in runtime, cause this makes things more difficult.In Delphi it runs like this :

function xy(bla bla bla) : DWORD; stdcall; external ''mydll.dll'';

Oh and a very very stupid question : Where''s the difference between stdcall, _stdcall and __stdcall ??
thanx for your support

This topic is closed to new replies.

Advertisement