听说有这样的API函数,可以在程序启动时把程序里的控件自己注册.
我有个flash控件,我也把他装载在了一个我网友给的控件里,我想的是当程序在其他电脑上运行时可以把这个flash控件(因为其他电脑上可能没有)自己注册到windows里,听说有这样的API函数,小弟愚氓,请各位帮帮忙.还有就是我的flash在程序里只能播放一次,不能循环播放,也请帮忙解释一下.我把shockwaveflash控件的LOOP已经设置为了true了,不行.

解决方案 »

  1.   

    这个好象不是API;
    Registers an in-process ActiveX server in the current module within the system registry.UnitComServCategoryCOM utilitiesDelphi syntax:function DllRegisterServer: HResult; stdcall;C++ syntax:STDAPI __export DllRegisterServer(void);DescriptionDo not call DllRegisterServer directly. DllRegisterServer is exported by in-process ActiveX servers (DLLs) and instructs the DLL to create its registry entries for the type library and all classes supported in that server module. DLLRegisterServer is usually called when the ActiveX server is installed on a user's system.If this function fails, the state of the registry for its type library and its classes is indeterminate.The return values for DllRegisterServer are as follows:Value MeaningS_OK The registry entries were created successfully.
    E_FAIL The registry entries were not completed.Note: DllRegisterServer is one of four functions in the ComServ unit that every in-process server must export so that Windows can manage the server resources properly. The others are DllCanUnloadNow, DllGetClassObject, and DllUnregisterServer.
      

  2.   

    procedure TForm1.RegControl(FileName:string);
      var
         h:Cardinal;
         Reg:procedure();stdcall;
    begin
         h:=LoadLibrary(Pansichar(FileName));
         @reg:=GetProcAddress(h,'DllRegisterServer');
         reg();
    end;
      

  3.   

    unit
      shellapi;shellexecute(handle, 'open', PChar('RegSvr32.exe Flash.ocx'), nil, nil, SW_HIDE);
    这样就注册了Flash.ocx了
      

  4.   

    楼上的老兄,用shellexecute不行,仍然不能注册.提示flash.ocx控件出错
      

  5.   

    TO;outer2000(天外流星)
    看了这个代码,好象不全,我在D的demo里找到这个,但是不懂,请看一下.
    procedure RegisterAxLib;
    begin
      LibHandle := LoadLibrary(PChar(FileName));
      if LibHandle = 0 then raise Exception.CreateFmt(SLoadFail, [FileName]);
      try
        @RegProc := GetProcAddress(LibHandle, ProcName[RegAction]);
        if @RegProc = Nil then
          raise Exception.CreateFmt(SCantFindProc, [ProcName[RegAction],
            FileName]);
        if RegProc <> 0 then
          raise Exception.CreateFmt(SRegFail, [ProcName[RegAction], FileName]);
        OutputStr(Format(SRegSuccessful, [ProcName[RegAction]]))
      finally
        FreeLibrary(LibHandle);
      end;
    end;procedure RegisterAxLib;
    begin
      LibHandle := LoadLibrary(PChar(FileName));
      if LibHandle = 0 then raise Exception.CreateFmt(SLoadFail, [FileName]);
      try
        @RegProc := GetProcAddress(LibHandle, ProcName[RegAction]);
        if @RegProc = Nil then
          raise Exception.CreateFmt(SCantFindProc, [ProcName[RegAction],
            FileName]);
        if RegProc <> 0 then
          raise Exception.CreateFmt(SRegFail, [ProcName[RegAction], FileName]);
        OutputStr(Format(SRegSuccessful, [ProcName[RegAction]]))
      finally
        FreeLibrary(LibHandle);
      end;
    end;procedure RegisterTLB;
    const
      RegMessage: array[TRegAction] of string = (SRegStr, SUnregStr);
    var
      WFileName, DocName: WideString;
      TypeLib: ITypeLib;
      LibAttr: PTLibAttr;
      DirBuffer: array[0..MAX_PATH] of char;
    begin
      if ExtractFilePath(FileName) = '' then
      begin
        GetCurrentDirectory(SizeOf(DirBuffer), DirBuffer);
        FileName := '\' + FileName;
        FileName := DirBuffer + FileName;
      end;
      if not FileExists(FileName) then
        raise Exception.CreateFmt(SFileNotFound, [FileName]);
      WFileName := FileName;
      OleCheck(LoadTypeLib(PWideChar(WFileName), TypeLib));
      OutputStr(Format(STlbName, [WFileName]));
      OleCheck(TypeLib.GetLibAttr(LibAttr));
      try
        OutputStr(Format(STlbGuid, [GuidToString(LibAttr^.Guid)]) + #13#10);
        if RegAction = raReg then
        begin
          OleCheck(TypeLib.GetDocumentation(-1, nil, nil, nil, @DocName));
          DocName := ExtractFilePath(DocName);
          OleCheck(RegisterTypeLib(TypeLib, PWideChar(WFileName), PWideChar(DocName)));
        end
        else begin
          OleAutLib := GetModuleHandle('OLEAUT32.DLL');
          if OleAutLib <> 0 then
            @UnRegTlbProc := GetProcAddress(OleAutLib, 'UnRegisterTypeLib');
          if @UnRegTlbProc = nil then raise Exception.Create(SCantUnregTlb);
          with LibAttr^ do
            OleCheck(UnRegTlbProc(Guid, wMajorVerNum, wMinorVerNum, LCID, SysKind));
        end;
      finally
        TypeLib.ReleaseTLibAttr(LibAttr);
      end;
      OutputStr(Format(STlbRegSuccessful, [RegMessage[RegAction]]));
    end;procedure RegisterEXE;
    var
      SI: TStartupInfo;
      PI: TProcessInformation;
      RegisterExitCode: BOOL;
    begin
      FillChar(SI, SizeOf(SI), 0);
      SI.cb := SizeOf(SI);
      RegisterExitCode := Win32Check(CreateProcess(PChar(FileName), PChar(FileName + ExeFlags[RegAction]),
        nil, nil, True, 0, nil, nil, SI, PI));
      CloseHandle(PI.hThread);
      CloseHandle(PI.hProcess);
      if RegisterExitCode then
        OutputStr(Format(SExeRegSuccessful, [PChar(FileName + ExeFlags[RegAction])]))
      else
        OutputStr(Format(SExeRegUnsuccessful, [PChar(FileName + ExeFlags[RegAction])]));
    end;begin
      try
        if not DecodeOptions then
          raise Exception.Create(SAbout + #13#10 + SUsage);
        OutputStr(SAbout);
        if not FileExists(FileName) then
          raise Exception.CreateFmt(SFileNotFound, [FileName]);
        case RegType of
          rtAxLib: RegisterAxLib;
          rtTypeLib: RegisterTLB;
          rtExeLib: RegisterEXE;
        end;
      except
        on E:Exception do OutputStr(E.Message);
      end;
    end.
                     这里到底哪个才是注册啊.太多了都不知道该用哪里??