频道分类

delphi 判断DLL动态链接库是否可用

作者:admin 来源: 日期:2020/3/5 21:37:57 人气: 标签:

 
这里只是演示代码:确保dll有这两个DllUnregisterServer DllRegisterServer
function RegisterServer(const aDllFileName: string; aRegister: Boolean): Boolean;
type
  TRegProc = function: HResult;
  stdcall;
const
  cRegFuncNameArr: array [Boolean] of PChar =
    ('DllUnregisterServer', 'DllRegisterServer');
var
  vLibHandle: THandle;
  vRegProc: TRegProc;
begin
  Result := False;
  vLibHandle := LoadLibrary(PChar(aDllFileName));
  if vLibHandle = 0 then Exit;
    @vRegProc := GetProcAddress(vLibHandle, cRegFuncNameArr[aRegister]);
  if @vRegProc <> nil then
    Result := vRegProc = S_OK;
  FreeLibrary(vLibHandle);
end;

上一篇:delphi 判断是否是0-9数字下一篇:没有资料