[阅读: 739] 2007-10-23 03:40:24
procedure RegisterAxLib( FileName: string );
type
TRegProc = function : HResult; stdcall;
TRegAction = (raReg, raUnreg);
var
LibHandle: THandle;
RegProc: TRegProc;
const
RegAction: TRegAction = raReg;
ProcName: array[TRegAction] of PChar = (
'DllRegisterServer', 'DllUnregisterServer');
begin
LibHandle := LoadLibrary(PChar(FileName));
if LibHandle = 0 then raise Exception.CreateFmt(SLoadFail, [FileName]);
try
@RegProc := GetProcAddress(LibHandle, ProcName[RegAction]);
if @RegProc = nil then
raise Exception.CreateFmt(SCantFindProc, [ProcName[RegAction], FileName]);
if RegProc <> 0 then
raise Exception.CreateFmt(SRegFail, [ProcName[RegAction], FileName]);
// OutputStr(Format(SRegSuccessful, [ProcName[RegAction]]))
finally
FreeLibrary(LibHandle);
end;
end;