Use the program to set the properties of the COM application.
Today, from the other machines, you will be registered on your own machine. You can view the properties of the COM application in the component service. The discovery agent has an attribute that can be modified, that is, the remote server name, change this name After the program does not need to use the CreateRemote function, you can also apply to a remote interface pointer. But we should give the user a friendly interface, can't always open the component service, come, let's write a program.
This time we only use the delphi control (, lazy just one word ^ _ ^)
Define three variables
Catacoll: tcomadmincatalogcollection;
Cataobj: TcomAdmincatalogObject;
Comadmincata: TcomAdmincatalog;
Begin
Comadmincata: = tcomadmincatalog.create (Self);
Catacoll: = Comadmincata.getCollection ('Applications');
Catacoll.Populate;
For i: = 0 to Catacoll.count - 1 DO
Begin
Cataobj: = Catacoll.get_Item (i);
If cataobj.name = Your app name THEN
Begin
Cataobj.Set_Value ('ApplicationProxyserverName ", new server name);
Catacoll.savechange; // Record to save modification
Break;
END;
END;
END;
The code is not long, the key function is set_value, the function prototype is as follows:
Procedure set_value (const bstrpropname: WideString; RetVal: Olevariant);
The key is the name of this bstrpropName - the name of the property, the string type, what is the string? I turned over MSDN, still didn't find what value, I guess it, I am not right. Microsoft is funny, giving a function, but not how to call, maybe I am stupid, did not find it. However, the stupidness also has a stupid approach to find these attribute values.
TcomAdminCatalogCollection This variable saves a collection, the variable is assigned by the getCollection function, and there is a description of these collections through the GetCollection function. It has found a PropertyInfo collection (like), so take it out and use for loop. Traverse, you can get the corresponding property name, the code is as follows:
Catacoll: = Catacoll.getCollection ('PropertyInfo', CataObj.get_Key);
Catacoll.Populate;
For J: = 0 to Catacoll.count - 1 DO
Begin
Cataobj: = catacoll.get_item (j);
Self.Memo1.Lines.Add (cataobj.name);
END;
You can read each property value from MEMO. The operation of the COM directory is a process of taking a collection and traversal collection.
The following is the name of each attribute name of the PropertyInfo collection, that is, the first parameter of the set_value method BSTRPROPNAME: Name
Id
Description
Issystem
Authentication
Shutdownafter
Runforever
Identity
Password
Activation
Changeable
Deleteable
CreateDby
AccessCheckslevel
ApplicationAccessChecksenabled
CommandLine
ImpersonationLevel
CRMENABLED
AuthenticationCapability
3gigsupportenabled
Queuingenabled
Queuelistenerenabled
Eventsenabled
ApplicationProxy
ApplicationProxyserverName
CRMLogfile