一、新建“应用程序”:
    Function CreateApplication(AppName: String): Boolean
二、删除“应用程序”:
    Function RemoveApplication(AppName: String): Boolean
三、新建“组件”:
    Function InstallComponent(AppName: String; DllName: String): Boolean
四、删除“组件”:
    Function RemoveComponent(AppName: String; DllName: String): Boolean
五、判断“应用程序”是否存在:
    Function IsAppplicationExists(AppName: String): Boolean即把手工注册COM+组件用程序来实现。
操作系统:WIN2K SERVER  或者 WIN2K ADNVANCED SERVER
谢谢。

解决方案 »

  1.   

    没有办法,到是可以通过Guid创建COM+对象,Guid从数据库中读!
      

  2.   

    Delphi里面就有:
    run|install com+ objects那也是用程序实现的呀。
      

  3.   

    自己摸索出来了,使用COM+|TCOMAdminCatalog
      

  4.   

    unit ComPlusAdmin;interfaceuses
      CmAdmCtl, Forms;  //一、新建“应用程序”:
      function CreateApplication(AppName: string): Boolean;
      //二、删除“应用程序”:
      function RemoveApplication(AppName: string): Boolean;
      //三、新建“组件”:
      function InstallComponent(AppName: string; DllName: string): Boolean;
      //四、删除“组件”:
      function RemoveComponent(AppName: string; DllName: string): Boolean;
      //五、判断“应用程序”是否存在:
      function IsAppplicationExists(AppName: string): Boolean;
      //六、启动“应用程序”
      function StartApplication(AppName: string): Boolean;
      //七、关闭“应用程序”
      function ShutdownApplication(AppName: string): Boolean;implementation//一、新建“应用程序”:
    function CreateApplication(AppName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
      objCatalogApplicationCollection: TCOMAdminCatalogCollection;
      objCatalogObject: TCOMAdminCatalogObject;
    begin
      Result := True;
      //checks if the Application exists or not, if not exists then creates the Application
      if not IsAppplicationExists(AppName) then
      begin
        try
          try
            objCatalog := TCOMAdminCatalog.Create(Application);
            objCatalogApplicationCollection := objCatalog.GetCollection('Applications');
            objCatalogApplicationCollection.Populate;
            objCatalogObject := objCatalogApplicationCollection.Add;
            objCatalogObject.Value['Name'] := AppName;
            objCatalogApplicationCollection.SaveChanges;
          except
            Result := False;
          end;
        finally          
          objCatalog.Destroy;
        end;
      end;
    end;//二、删除“应用程序”:
    function RemoveApplication(AppName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
      objCatalogApplicationCollection: TCOMAdminCatalogCollection;
      iCounter: Integer;
    begin
      try
        try
          objCatalog := TCOMAdminCatalog.Create(Application);
          //getting all the Applications in the server
          objCatalogApplicationCollection := objCatalog.GetCollection('Applications');
          objCatalogApplicationCollection.Populate;
          //looping through all the Applications to test whether the Application exists
          Result := False;
          for iCounter := 0 to objCatalogApplicationCollection.Count-1 do
          begin
            //Debug.Print objCatalogApplicationCollection.Item(iCounter).Name
            if objCatalogApplicationCollection.Get_Item(iCounter).Name = AppName then
            begin
              //Shutdown the application first
              objCatalog.ShutDownApplication(AppName);
              objCatalogApplicationCollection.Remove(iCounter);
              objCatalogApplicationCollection.SaveChanges;
              Result := True;
              Break;
            end;
          end;
        except
          Result := False;
        end;
      finally
        objCatalog.Destroy;
      end;
    end;//三、新建“组件”:
    function InstallComponent(AppName: string; DllName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
    begin
      try
        try
          objCatalog := TCOMAdminCatalog.Create(Application);
          objCatalog.InstallComponent(AppName, DllName, '','');
          Result := True;
        except
          Result := False;
        end;
      finally
        objCatalog.Destroy;
      end;
    end;//四、删除“组件”:
    function RemoveComponent(AppName: string; DllName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
      objCatalogApplicationCollection: TCOMAdminCatalogCollection;
      objCatalogComponentCollection: TCOMAdminCatalogCollection;
      iCounter: Integer;
      iComponentCounter: Integer;
      bRemoved: Boolean;
    begin
      Result := True;
      try
        try
          objCatalog := TCOMAdminCatalog.Create(Application);
          //getting all the Applications in the server
          objCatalogApplicationCollection := objCatalog.GetCollection('Applications');
          objCatalogApplicationCollection.Populate;      //looping through all the Applications to get the current Application
          for iCounter := 0 to objCatalogApplicationCollection.Count-1 do
          begin
            if objCatalogApplicationCollection.Get_Item(iCounter).Name = AppName then
            begin
              //if application is found Shutdown the application first
              objCatalog.ShutDownApplication(AppName);
              //getting the current collection
              objCatalogComponentCollection := objCatalogApplicationCollection.GetCollection
                  ('Components', objCatalogApplicationCollection.Get_Item(iCounter).Key);
              objCatalogComponentCollection.Populate;
              //check if the remove option is enabled
              if objCatalogComponentCollection.RemoveEnabled then
              begin
                for iComponentCounter := 0 to objCatalogComponentCollection.Count-1 do
                begin
                  //remove the component, which is always the top one
                  objCatalogComponentCollection.Remove(0);
                end;
              end
              else
              begin
                Result := False;
                //raise an error
              end;
              //saves changes
              objCatalogComponentCollection.SaveChanges;
            end;
          end;
        except
          Result := False;
        end;
      finally
        objCatalog.Destroy;
      end;
    end;//五、判断“应用程序”是否存在:
    function IsAppplicationExists(AppName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
      objCatalogApplicationCollection: TCOMAdminCatalogCollection;
      iCounter: Integer;
    begin
      try
        try
          Result := False;
          //getting all the Applications in the server
          objCatalog := TCOMAdminCatalog.Create(Application);
          objCatalogApplicationCollection := objCatalog.GetCollection('Applications');
          objCatalogApplicationCollection.Populate;
          //looping through all the Applications to test whether the Application exists
          for iCounter := 0 to objCatalogApplicationCollection.Count - 1 do
          begin
            if objCatalogApplicationCollection.Get_Item(iCounter).Name = AppName then
            begin
              Result := True;
              Break;
            end;
          end;
        except
          Result := False;
        end;
      finally
         objCatalog.Destroy;
      end;
    end;//六、启动“应用程序”
    function StartApplication(AppName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
    begin
      try
        try
          //starts the Application in COM+
          objCatalog := TCOMAdminCatalog.Create(Application);
          //starting the application
          objCatalog.StartApplication(AppName);
          Result := True;
        except
          Result := False;
          //raise the error
        end;
      finally
        objCatalog.Destroy;
      end;
    end;//七、关闭“应用程序”
    function ShutdownApplication(AppName: string): Boolean;
    var
      objCatalog: TCOMAdminCatalog;
    begin
      try
        try
          //shut down the Application in COM+
          objCatalog := TCOMAdminCatalog.Create(Application);
          //shut down the application
          objCatalog.ShutDownApplication(AppName);
          Result := True;
        except
          Result := False;
          //raise the error
        end;
      finally
        objCatalog.Destroy;
      end;
    end;end.
      

  5.   

    废话少说快贴代码啊!!!
    我可等着code呢
      

  6.   

    百合是MM,所以分多给了点,其实其他朋友也可以了,UP一下就有10,我可从来没这运气。呵呵。