[php]
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.

[/php]

  • 相关文章

    • 无相关文章
最后修改:2009 年 08 月 16 日
卧槽,全是白嫖客,服务器不要钱吗?