中国开发网: 论坛: Delphi/BCB: 贴子 574578
没脾气2x: 给你贴段代码。
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;

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录