调用DLL中的函数可分为早绑定与晚绑定!
早绑定是指在编译期就已经确定函数地址!
晚绑定是指在运行期动态加载dll,并根据查表的方式获取dll内exports函数的地址,由于早绑定比较简单,在此不再讲述,主要说晚绑定!
//晚绑定,也就是动态调用外部函数主要用以下三个命令:
//LoadLibrary:获取 DLL
//GetProcAddress:获取函数
//FreeLibrary:释放DLL
例:

type TFunctionName=function():boolean;stdcall;//定义函数类型 Function DynamicInvokeDllFunction: string; var DllHnd: THandle; FunctionName: TFunctionName; begin DllHnd := LoadLibrary(PChar('dll文件名')); try if (DllHnd <> 0) then begin @FunctionName:=GetProcAddress(DllHnd, 'Dll接口名称'); if (@FunctionName<>nil) then begin try FunctionName(); finally end; end else begin application.MessageBox(PChar('DLL加载出错,DLL可能不存在!'), PChar('错误'), MB_ICONWARNING or MB_OK); end; end; finally FreeLibrary(DllHnd); end; end;