From: John Brown <johnbrown105@ho...> - 2002-11-18 12:13:11
"guidance_shanghai" <guidance_shanghai@...> wrote:
>I'm wondering why we need .def and .lib to link with a run-time DLL?
>Why in VB it's so simple? Can't we just define/declare the functions
>in header file to interface with DLL?
VB makes a lot of things easy. The method that it uses behind the scenes can
be used in C/C++ programs as well, but it is somewhat tedious if you need to
call a lot of functions in the library. You can use:
hinstDLL = LoadLibrary("MyDLL");
ptrMyFunc = GetProcAddress(hInstDLL, "MyFunc"). See the Win32 API
documentation for details. The trouble is that for each function that you
want to call, you must declare a suitable pointer type. For example, to
BOOL WINAPI ShowWindow(HWND,int) you need to declare:
typedef BOOL (WINAPI *ptrTypeShowWindow)(HWND, int);
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*