Advertisement

DLLs

Started by March 04, 2003 12:31 PM
3 comments, last by Jess 21 years, 8 months ago
If I have a function in a dll, and this function is called by main program too much times (GLRender() the system gets the function code one time at begining, or every time it get the function of the dll. There are much overhead in DLL functions call?
Assuming you retrieve the function address just once and not every time you call it, the difference between calling a function and calling one in a DLL should be negligible.
Advertisement
Once DLL is loaded there is NO difference. In-process DLL code is treated exactly as any function in main module. And as good doctor recommends save that pointer.
Oh thanks!

Another question:

What is best way to use DLLs?
1. main.cpp and main.h with
main.h: __declspec(dllexport) int func();
main.cpp: __declspec(dllexport) int func() { return 1+1; }

out: main.dll and main.lib
in program that use the dll: link the main.lib and call the function normal: int main() { int n = func(); ... }
or

2. HINSTANCE hDLL = LoadLibrary("main.dll");
GetModuleFileName(....)
func = (cfunc)GetProcAddress((HMODULE)hDLL,"func");
int n = func();
FreeLibrary((HMODULE)hDLL);
Depends, if you can relly on the présence of this dll, use .lib if not use LoadLibrary, so you can handle the case that the library is absent.
_______________
Jester, studient programmerThe Jester Home in French

This topic is closed to new replies.

Advertisement