关闭

AoInitailize 权限

标签: initializationextensionfunctionintegeraccesssystem
1049人阅读 评论(0) 收藏 举报
分类:
[Visual Basic 6.0]
Option Explicit
Private m_pAoInitialize As IAoInitialize

Private Sub Form_Load()
  'This sample is designed to perform license initialization on a system
  'that may have access to a floating license. It requires GDB editing
  'capability and A spatial Analyst extension
  
  'This sample will check the required licenses and keep them checked out
  Dim licenseStatus As esriLicenseStatus
  'First try copy protection EngineGeoDB
  licenseStatus = CheckOutLicenses(esriLicenseProductCodeEngineGeoDB)
  If (licenseStatus = esriLicenseNotLicensed) Then
    'Next try Desktop ArcEngine
    licenseStatus = CheckOutLicenses(esriLicenseProductCodeArcEditor)
    'For Desktop licenses we also need to consider them being unavailable
    If ((licenseStatus = esriLicenseNotLicensed) Or (licenseStatus = esriLicenseUnavailable)) Then
      'Last try Desktop ArcInfo
      licenseStatus = CheckOutLicenses(esriLicenseProductCodeArcInfo)
    End If
  End If
  
  'Take a look at the licenseStatus to see if it failed
  'Not licensed
  If (licenseStatus = esriLicenseNotLicensed) Then
    MsgBox "You are not licensed to run this product"
    Unload Form1
  'The licenses needed are currently in use
  ElseIf (licenseStatus = esriLicenseUnavailable) Then
    MsgBox "There are insufient licenses to run"
    Unload Form1
  'The licenses unexpected license failure
  ElseIf (licenseStatus = esriLicenseFailure) Then
    MsgBox "Unexpected license failure please contact you administrator'"
    Unload Form1
  'Already initialized (Initialization can only occur once)
  ElseIf (licenseStatus = esriLicenseAlreadyInitialized) Then
    MsgBox "You license has already been initialized please check you implementation"
    Unload Form1
  'Everything was checkedout successfully
  ElseIf (licenseStatus = esriLicenseCheckedOut) Then
    MsgBox "Licenses checked out successfully"
  End If
  
End Sub

Private Sub Form_Unload(Cancel As Integer)

  'Checkin the extension
  m_pAoInitialize.CheckInExtension (esriLicenseExtensionCodeSpatialAnalyst)
  'Shutdown
  m_pAoInitialize.Shutdown

End Sub

Private Function CheckOutLicenses(productCode As esriLicenseProductCode) As esriLicenseStatus
  
  Dim licenseStatus As esriLicenseStatus
  Set m_pAoInitialize = New AoInitialize
  CheckOutLicenses = esriLicenseUnavailable
    
  'Check the productCode
  licenseStatus = m_pAoInitialize.IsProductCodeAvailable(productCode)
  If (licenseStatus = esriLicenseAvailable) Then
    'Check the extensionCode
    licenseStatus = m_pAoInitialize.IsExtensionCodeAvailable(productCode, esriLicenseExtensionCodeSpatialAnalyst)
    If (licenseStatus = esriLicenseAvailable) Then
      'Initialize the license
      licenseStatus = m_pAoInitialize.Initialize(productCode)
      If (licenseStatus = esriLicenseCheckedOut) Then
          'Checkout the extension
        licenseStatus = m_pAoInitialize.CheckOutExtension(esriLicenseExtensionCodeSpatialAnalyst)
      End If
    End If
  End If
  
  CheckOutLicenses = licenseStatus
  
End Function
 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:868430次
    • 积分:11793
    • 等级:
    • 排名:第1325名
    • 原创:168篇
    • 转载:533篇
    • 译文:7篇
    • 评论:293条
    最新评论
    黑客
    代码下载