一个通用的动态装载DLL的函数

[赣]Bahamut(28103589) 10:31:20

function LoadDLL(const DLLName, FuncName: string): Pointer; 

var    hModule: Windows.HMODULE;

 begin   

Result:= nil;   

if not FileExists(DLLName) then    Exit;

  hModule:= LoadLibrary(PChar(DLLName));

  if hModule = 0 then    Exit;  

 try   

Result:= GetProcAddress(hModule, PChar(FuncName)); 

 finally   

FreeLibrary(hModule); 

end;

end;

posted @ 2008-06-21 10:56  delphi中间件  阅读(307)  评论(0编辑  收藏  举报