Displays the name of the product license used to initialize the application and the names of any extension licenses currently checked out by the application.
[C#]
/// <summary> /// Displays the name of the product license used to initialize the application and /// the names of any extension licenses currently checked out by the application. /// </summary> /// <remarks>If the ArcObjects application is not initialized an exception will be thrown and error message displayed.</remarks> public void DisplayProductLicenseAndExtensionsInformation() { //Create an AOInitialize object ESRI.ArcGIS.esriSystem.IAoInitialize aoInitialize = new ESRI.ArcGIS.esriSystem.AoInitializeClass(); ESRI.ArcGIS.esriSystem.ILicenseInformation licenseInformation = (ESRI.ArcGIS.esriSystem.ILicenseInformation)aoInitialize; // Explict Cast System.String string_Licenses = null; try { ESRI.ArcGIS.esriSystem.esriLicenseProductCode licenseProductCode = aoInitialize.InitializedProduct(); System.String string_LicenseProductName = licenseInformation.GetLicenseProductName(licenseProductCode); //Get the name of the application's initialized product string_Licenses = "This application is initialized with the following product license:" + System.Environment.NewLine + string_LicenseProductName + System.Environment.NewLine + "This application has the following extension licenses checked out:"; //Get the extension enumerator for the initialized product ESRI.ArcGIS.esriSystem.ILicenseInfoEnum licenseInfoEnum = licenseInformation.GetProductExtensions(licenseProductCode); //Reset the enumerator licenseInfoEnum.Reset(); //Get the next extension code ESRI.ArcGIS.esriSystem.esriLicenseExtensionCode licenseExtensionCode = licenseInfoEnum.Next(); //Loop through the extension codes while ( ! (System.Convert.ToInt32(licenseExtensionCode) == -1)) { //Get the name of the extension if it checked out if (aoInitialize.IsExtensionCheckedOut(licenseExtensionCode) == true) { System.String string_LicenseExtensionName = licenseInformation.GetLicenseExtensionName(licenseExtensionCode); string_Licenses = string_Licenses + System.Environment.NewLine + string_LicenseExtensionName; } //Get the next extension code licenseExtensionCode = licenseInfoEnum.Next(); } System.Windows.Forms.MessageBox.Show(string_Licenses); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
[Visual Basic .NET]
''' <summary> ''' Displays the name of the product license used to initialize the application and ''' the names of any extension licenses currently checked out by the application. ''' </summary> ''' <remarks>If the ArcObjects application is not initialized an exception will be thrown and error message displayed.</remarks> Public Sub DisplayProductLicenseAndExtensionsInformation() 'Create an AOInitialize object Dim aoInitialize As ESRI.ArcGIS.esriSystem.IAoInitialize = New ESRI.ArcGIS.esriSystem.AoInitializeClass Dim licenseInformation As ESRI.ArcGIS.esriSystem.ILicenseInformation = CType(aoInitialize, ESRI.ArcGIS.esriSystem.ILicenseInformation) ' Explict Cast Dim string_Licenses As System.String = Nothing Try Dim licenseProductCode As ESRI.ArcGIS.esriSystem.esriLicenseProductCode = aoInitialize.InitializedProduct Dim string_LicenseProductName As System.String = licenseInformation.GetLicenseProductName(licenseProductCode) 'Get the name of the application's initialized product string_Licenses = "This application is initialized with the following product license:" _ + System.Environment.NewLine + string_LicenseProductName _ + System.Environment.NewLine + "This application has the following extension licenses checked out:" 'Get the extension enumerator for the initialized product Dim licenseInfoEnum As ESRI.ArcGIS.esriSystem.ILicenseInfoEnum = licenseInformation.GetProductExtensions(licenseProductCode) 'Reset the enumerator licenseInfoEnum.Reset() 'Get the next extension code Dim licenseExtensionCode As ESRI.ArcGIS.esriSystem.esriLicenseExtensionCode = licenseInfoEnum.Next 'Loop through the extension codes Do Until System.Convert.ToInt32(licenseExtensionCode) = -1 'Get the name of the extension if it checked out If aoInitialize.IsExtensionCheckedOut(licenseExtensionCode) = True Then Dim string_LicenseExtensionName As System.String = licenseInformation.GetLicenseExtensionName(licenseExtensionCode) string_Licenses = string_Licenses + System.Environment.NewLine + string_LicenseExtensionName End If 'Get the next extension code licenseExtensionCode = licenseInfoEnum.Next Loop System.Windows.Forms.MessageBox.Show(string_Licenses) Catch ex As System.Exception System.Windows.Forms.MessageBox.Show(ex.ToString) End Try End Sub