用 delphi 做了一个 ocx ,也做成 cab 了,但是本机测试的时候还是不能看见,然后 手工注册了一下,才可以。
接这用其他机器调用了,ocx 应该已经下载了,但是仍然看不见。请教各为大师,帮帮我一下,如何自动注册,多谢了!!! 

解决方案 »

  1.   

    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. 
    //自己收集的资料
      

  2.   

    两种可能
    1 下载没有成功(表面上看下下来了)
    2 activeX被禁用了