我有个OCX控件TEST.OCX需要安装和注册才能调用,我必须把控件拷贝到system32文件夹里,然后注册,请问在程序里怎么实现这两步,我的TEST.OCX在我的程序的根目录底下另一个问题,我想把注册表里的某项下的一些值修改
例如在HKEY_LOCAL_MACHINE software\TEST\sum 下面有很多值
A1  REG_SZ  1212
B1  REG_SZ  4544 A2  REG_SZ  5656
B2  REG_SZ  67567A3  REG_SZ  5432
B3  REG_SZ  9509........
我现在想把这些值的A和B后面数字都递增1,这样原来的就变成
A2  REG_SZ  1212
B2  REG_SZ  4544 A3  REG_SZ  5656
B3  REG_SZ  67567A4  REG_SZ  5432
B4  REG_SZ  9509
.............
请问怎么实现

解决方案 »

  1.   

    type
      DLLRegProc=function :HResult;
    //注册OCX/DLL
    function DLLReg(const FileName:PChar):Boolean;
    var
       lib: THandle;
       func:TFarProc;
       DLLRegProcL:DLLRegProc;
    begin
       Result:=false;
       if not FileExists(FileName) then exit;
       lib := LoadLibrary(PChar(FileName));
       if(lib=0) then exit;
       try
          func:=GetProcAddress(lib,'DllRegisterServer');
          if not Assigned(func) then exit;
          DLLRegProcL:=DLLRegProc(func);
          Result:=DLLRegProcL=S_OK;
       finally
          FreeLibrary(lib);
       end;
    end;
    //反注册OCX/DLL
    function DLLUnReg(const FileName:PChar):Boolean;
    var
       lib: THandle;
       func:TFarProc;
       DLLRegProcL:DLLRegProc;
    begin
       Result:=false;
       if not FileExists(FileName) then exit;
       lib := LoadLibrary(PChar(FileName));
       if(lib=0) then exit;
       try
          func:=GetProcAddress(lib,'DllUnregisterServer');
          if not Assigned(func) then exit;
          DLLRegProcL:=DLLRegProc(func);
          Result:=DLLRegProcL=S_OK;
       finally
          FreeLibrary(lib);
       end;
    end;end.
      

  2.   

    var
    reg:TRegistry;
    begin
       reg:=TRegistry.Create;
       reg.RootKey:=HKEY_xxx ;//HKEY_LOCAL_MACHINE
       reg.OpenKey('xxxx',false);
       reg.RenameValue(OldName,NewName);
       reg.CloseKey;
       reg.Free;
    end;
      

  3.   

    use comobj函数:
    procedure RegisterComServer(const DLLName: string);
      

  4.   

    WinExec('regsvr32.exe /s xxx.ocx',SW_SHOWNORMAL);
      

  5.   

    楼上正解,简单明了!
      WinExec(PChar('regsvr32.exe /s flash.ocx'), SW_SHOWNORMAL);
      

  6.   

    同意WinExec(PChar('regsvr32.exe /s test.ocx'), SW_HIDE);这样改一下就完美了