'函数名称:DeleteComponent'作用:删除对应com+应用中的组件'参数:sFolder COM+目录,sFileName组件名Public Function DeleteComponent(sComFolder As String, sFileName As String) As Boolean Dim oo As Object Dim oKey As Variant Dim oComponents As Object Dim i As Integer On Error GoTo Errd oCatcol.Populate For Each oo In oCatcol If oo.name = sComFolder Then oKey = oo.Key End If Next Set oComponents = oCatcol.GetCollection("Components", oKey) oComponents.Populate If oComponents.Count > 0 Then i = 0 For Each oo In oComponents If oo.name = sFileName Then oComponents.Remove i oComponents.SaveChanges Exit For End If i = i + 1 Next End If DeleteComponent = True Exit FunctionErrd:End Function以上代码是卸载com+组件的,但是上面的sFileName 并不是dll的文件名,而是“工程名.类模块名”,我怎么才能根据dll名获得它的所有类模块名?比如说我有个编译好名为test.dll 的com+组件,本身没编译前的工程里有这三个类名clsInfo,clsUpdate,clsOther.如果是把组件手工拖到com+组件服务里面某个应用下的话就会这样展示:test.clsInfo,test.clsUpdate,test.clsOther,我想要的就是怎么才能获取这三个名称出来,用于以上的卸载
6条回答 默认 最新
WorldMobile 2015-04-27 00:31关注在delphi可以这么写,你参考一下
//卸载COM+应用程序
function UnInstallCOMApplication:Boolean;stdcall;
const
SComApplicationName = '你的应用程序名';
var
COMAdminCatalog : OleVariant;
CatalogCollection : OleVariant;
i : Integer;
begin
try
COMAdminCatalog := CreateOleObject('COMAdmin.COMAdminCatalog');
CatalogCollection := COMAdminCatalog.GetCollection('Applications');
CatalogCollection.Populate;
for i := 0 to CatalogCollection.Count - 1 do
if CatalogCollection.Item[i].Name = SComApplicationName then
begin
CatalogCollection.Remove(i);
CatalogCollection.SaveChanges;
Break;
end;
Result := True;
except
Result := False;
end;
end;解决 无用评论 打赏 举报