Programmatic administration of COM+ Applications with the COM+ Admin objects in VC++
Ranjeet Chakraborty.
ranjeetc@hotmail.com
Environment: [VC++ 6.0, VB 6.0, Windows 2000]
I started exploring programmatic administration of COM+ applications when we came across the requirement of changing the components constructor string via an MMC snapin as well as allow the flexibility to add a predetermined set of roles and allocate users to them at one shot via some installation script.
The project involved a typical WinDNA application with COM+ components holding the business logic in the middle tier. A setup application installed the COM+ application with the components and all their attributes.
Typically every com+ application has the following configurable parameters of which some could be set through the component services tool and some cant :
For details refer MSDN/ Platform SDK/Component Services/COM+/Reference/COM+ Administrators Reference
AccessChecksLevel, Activation, ApplicationAccessChecksEnabled, ApplicationProxy, ApplicationProxyServerName, Authentication, AuthenticationCapability, Changeable, CommandLine, CreatedBy, CRMEnabled, CRMLogFile, Deleteable, Description, EventsEnabled, ID, ImpersonationLevel, Identity, IsSystem, Name, Password, QueuingEnabled, QueueListenerEnabled, RunForever, ShutdownAfter, 3GigSupportEnabled .
For individual Components in the application following parameters are configured:
AllowInprocSubscribers, ApplicationID, CLSID, ComponentAccessChecksEnabled, COMTIIntrinsics, ConstructionEnabled, ConstructorString, CreationTimeout, Description, DLL, EventTrackingEnabled, ExceptionClass, FireInParallel, IISIntrinsics, IsEventClass, JustInTimeActivation, LoadBalancingSupported, MaxPoolSize, MinPoolSize, MultiInterfacePublisherFilterCLSID, MustRunInClientContext, ObjectPoolingEnabled, ProgID, PublisherID, Synchronization, ThreadingModel,Transaction, VersionBuild, VersionMajor, VersionMinor, VersionSubBuild.
The complete list for other related collections like Roles, RolesForComponent, etc could be found in the Platform Sdk doc.
A programmatic approach to configure all the above parameters is provided via the com+ administration objects.
The administration objects provide a way to access and manipulate all of the COM+ configuration data otherwise accessible through the Component Services administration tool. You can use these objects to automate all tasks in COM+ administration. These admin objects let us read and write information stored on the COM+ catalog, the underlying data store that holds all COM+ configuration data.
Throughout MSDN and the platform SDK there was no sample code available for VC++ developers (at least I couldnt find any) So I decided to write one.
Visual studio doesnt come with the header files or IDL files for COMAdmin.dll. So it isnt as easy as including the header file in your project and getting to work with CoCreateInstance for the appropriate interface on the appropriate coclass.
The COM+ 1.0 Type Library in OLEVIEW looks something like this.
What I found was that The COM+ admin objects consists of three components(coclasses in idl). Each of them having one main dispinterface as the default interface(as each coclass implemented one interface only). For example the coclass COMAdminCatalog implemented one interface ICOMAdminCatalog.
coclass COMAdminCatalog {
[default] interface ICOMAdminCatalog;
};
This component represents the COM+ Catalog Manager.
The reason I guess these components exposed dispinterfaces were because they needed to be accessed via installation scripts run under WSH or through VB.
Talking more about the objects, There are logical collections such as Applications, Components and Roles which map to COMAdminCatalogCollection component.Similarly logical collections like Application, Component and Role map to the COMAdminCatalogObject component.The COMAdminCatalog stands as the root object and it contains the Applications Collection.The Roles and the Components collection could be retrieved from the Applications collection. Similarly the other collections specific to a component say "RolesForComponent" could be retrieved from the Components collection.
Did I hear yukss when I said dispinterfaces. GOSH!! Isn;t that a PAIN to program in C++ - GetIdOfNames, DISPIDS, Invoke.
Vb developers never have to deal with raw VARIANT structures, setting discriminants, calling SysAllocString to allocate BSTR's. But in C++ we have to !
Does that mean it is difficult to code COM+ admin objects in c++ ?
NO ! the sample code uses the #import directive to incorporate information from the COM+ admin type library.
The sample is a simple Win32 application. With a little smart pointer code, the code looks similar to VB code. :)
All you gotta say is
#import "c:\\winnt\\system32\\com\\Comadmin.dll" no_namespace
The no_namespace directs the compiler not to generate the type library information in a namespace, and hence contents like Interface names need not be be prefixed with the namespace::
There , and you are all set to use the components without ever knocking on IUnknown's door. All the AddRef(), Release() and QueryInterface happen silently.
For example :
ICOMAdminCatalogPtr spCatalog("COMAdmin.COMAdminCatalog");
The above call is translated to a cocreateinstance call for the COMAdminCatalog component and a pointer to the interface is retrieved.
The rest of the code is similar to VB.
The sample does the following
Creates a HelloWorld COM+ Application called "HelloWorld",
Installs a HelloWorld component in to the application,
Sets the different Roles that the application might need,
Sets the roles explicitly for every component(one in this case)
Sets the ConstructorString for the component.
I have included a sample VB activeX dll project HelloWorld.vbp which exposes a method, you could replace that with your own component if you wish to.
CHANGE the default value of the #defines if you wish to override default values for the HelloWorld application.
ESPECIALLY the value of the HELLOWORLD_DLL_PATH to reflect the path where the VB Sample DLL is located.
Please change the path of the component in the #define to reflect the path of the component you wish to include in the COM+ application
Please find attached the demo project with the HelloWorld VB component, that could be used to add to the com+ application.
This article is a result of my experiences with the programming of COM+ admin objects. I assume that the application will be running under adequate user rights.
If the code works, its written by me, or I dont know who the hell wrote it.
References:
Platform SDK documentation,
Ted Pattison's article on COM+ admin objects on MSDN.
Downloads
Download demo project with source - [49.9] Kb
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
complus_admin.zip (14个子文件)
HelloCOMAdmin
HelloCOMAdmin.dsw 551B
Comadmin.tlh 19KB
Release
HelloCOMAdmin.exe 56KB
HelloCOMAdmin.plg 1KB
Comadmin.tli 13KB
HelloCOMAdmin.dsp 4KB
StdAfx.cpp 300B
StdAfx.h 773B
HelloWorldVB
HelloWorld.dll 24KB
HelloWorld.vbw 29B
Hello.cls 681B
HelloWorld.vbp 873B
HelloCOMAdmin.cpp 7KB
ReadMe.txt 7KB
共 14 条
- 1
资源评论
普通网友
- 粉丝: 882
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- tensorflow-2.7.3-cp39-cp39-manylinux2010-x86-64.whl
- tensorflow-2.7.2-cp39-cp39-manylinux2010-x86-64.whl
- Python版本快速排序源代码
- Python 语言版的快速排序算法实现
- 450815388207377安卓_base.apk
- 超微主板 X9DRE-TF+ bios 支持 nvme启动
- 基于Python通过下载气象数据和插值拟合离散数据曲线实现对寒潮过程的能量分析
- 健身房系统的设计与实现论文Java项目
- 使用TCP实现的搜索可用服务器
- 使用贪心算法解决会议时间安排问题的 Java 示例代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功