program RegOcxSample; uses Forms, SysUtils, Dialogs, ActiveX, Windows, Unit1 in 'Unit1.pas' {Frm_Main}; {$R *.res} var OCXHand:THandle; RegFunc:TDLLRegisterServer; sfile:string; begin Application.Initialize; //运行程序前先注册OCX文件 sfile:=ExtractFilePath(Application.ExeName)+myocx.ocx'; if not FileExists(sfile) then begin ShowMessage(myocx.ocx文件丢失,请重新安装程序!'); Application.Terminate; end;
try OCXHand:=LoadLibrary(PChar(sfile)); RegFunc:=GetProcAddress(OCXHand, 'DllRegisterServer'); if RegFunc <> 0 then begin ShowMessage('myocx.ocx注册失败!'); Application.Terminate; end; finally FreeLibrary(OCXHand); end; Application.CreateForm(TFrm_Main, Frm_Main); Application.Run; end. //自己收集的资料
uses
Forms,
SysUtils,
Dialogs,
ActiveX,
Windows,
Unit1 in 'Unit1.pas' {Frm_Main};
{$R *.res}
var
OCXHand:THandle;
RegFunc:TDLLRegisterServer;
sfile:string;
begin
Application.Initialize;
//运行程序前先注册OCX文件
sfile:=ExtractFilePath(Application.ExeName)+myocx.ocx';
if not FileExists(sfile) then
begin
ShowMessage(myocx.ocx文件丢失,请重新安装程序!');
Application.Terminate;
end;
try
OCXHand:=LoadLibrary(PChar(sfile));
RegFunc:=GetProcAddress(OCXHand, 'DllRegisterServer');
if RegFunc <> 0 then
begin
ShowMessage('myocx.ocx注册失败!');
Application.Terminate;
end;
finally
FreeLibrary(OCXHand);
end; Application.CreateForm(TFrm_Main, Frm_Main);
Application.Run;
end.
//自己收集的资料
1 下载没有成功(表面上看下下来了)
2 activeX被禁用了