[C#]// This example shows how to change the class extension of an extension object or feature class.
// The extensionName parameter is used to set the Value property of a UID object; the string can// be in ProgID format ("MyProject.ClassExtension") or GUID format ("{484F435C-9A08-11D3-815A-0080C78E8371}").// The extProperties parameter should contain the extension properties (in many cases, there are no// properties, and this can be passed a null value).public void ChangeClassExtension(IObjectClass objectClass, String extensionName, IPropertySet extProperties){
// Attempt to acquire an exclusive schema lock for the object class. ISchemaLock schemaLock = (ISchemaLock)objectClass; try{
schemaLock.ChangeSchemaLock(
esriSchemaLock.esriExclusiveSchemaLock);// If this point is reached, the exclusive lock was acquired. We can cast the object
// class to IClassSchemaEdit. IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)objectClass;// Create a UID object for the class extension.
UID uid = new UIDClass();uid.Value = extensionName;
// Call AlterClassExtensionCLSID to change the extension CLSID. To leave the class without
// an extension, both of the parameters should be given null values.classSchemaEdit.AlterClassExtensionCLSID(uid, extProperties);
}
catch (COMException comExc){
// Re-throw the exception. throw comExc;}
finally{
// Reset the lock on the object class to a shared lock.schemaLock.ChangeSchemaLock(
esriSchemaLock.esriSharedSchemaLock);}
}
[Visual Basic 6.0, Visual Basic .NET, C++]
No example is available for Visual Basic 6.0, Visual Basic .NET, or C++. To view a C# example, click the Language Filter button
in the upper-left corner of the page.