我想在delphi程序中将两个*.ocx写入注册表,请问该怎么实现?

解决方案 »

  1.   

    usesWinProcs;
    ...
    begin
    WinExec(......);
    ….
    end.
    和调用Pascal库函数没什么两样。
      

  2.   

    直接加载它并调用DLLREGISTER接口
      

  3.   

    uses OleCtl //..\Borland\Delphi6\Source\Rtl\Win\OleCtl.pas
    var
        OCXHand: THandle;
        RegFunc: TDllRegisterServer;
    begin
        Try
            OCXHand:= LoadLibrary('c:\test.ocx');
            RegFunc:= GetProcAddress(OCXHand, 'DllRegisterServer');
            if RegFunc <> 0 then
               MessageBox(Application.Handle,'不能注册文件!','信息提示',
                           MB_ICONINFORMATION+MB_OK);
            else
               MessageBox(Application.Handle,'注册文件成功!','信息提示',
                           MB_ICONINFORMATION+MB_OK);   
        finally
            FreeLibrary(OCXHand);
        end;
    end;
      

  4.   

    uses OleCtl //文件在目录下:'..\Borland\Delphi6\Source\Rtl\Win\OleCtl.pas'
    var
        OCXHand: THandle;
        RegFunc: TDllRegisterServer;
    begin
        Try
            OCXHand:= LoadLibrary('c:\test.ocx');
            RegFunc:= GetProcAddress(OCXHand, 'DllRegisterServer');
            if RegFunc <> 0 then
               MessageBox(Application.Handle,'不能注册文件!','信息提示',
                           MB_ICONINFORMATION+MB_OK)
            else
               MessageBox(Application.Handle,'注册文件成功!','信息提示',
                           MB_ICONINFORMATION+MB_OK);   
        finally
            FreeLibrary(OCXHand);
        end;
    end;
      

  5.   

    How to register an OCX
    Your installation program needs to register an OCX, but doesn't support this? Or you want to
    register it by your program yourself? Suppose the OCX you want to use is called    
     program RegisterMyOCX;
    uses
      OLECtl, Windows, Dialogs;
    var
      OCXHand: THandle;
      RegFunc: TDllRegisterServer;   //add  to the uses clause
    begin
      OCXHand:= LoadLibrary('c:\windows\system\test.ocx');
      RegFunc:= GetProcAddress(OCXHand, 'DllRegisterServer');  //case sensitive
      if RegFunc <> 0 then 
        RegFunc
      else
        ShowMessage('Error!')
      FreeLibrary(OCXHand);  // You can the same way unregister the OCX: 
      // replace 'DllRegisterServer' by 'DllUnregisterServer'
    end.
      

  6.   

    ShellExceute

    WinExec
    不过还是用
    ShellExceute
    保险点
      

  7.   

    用SHELLEXCEUTE。
    要把regsvr32.exe那个文件也打包到程序中才行。
    不然有的机器没有regsvr32就死定了。还是同意楼上一星级战友的意见!