SetLicenseFlags Enumeration

Summary

Defines the possible flags for setting the license.

Syntax
C#
VB
C++
public enum SetLicenseFlags   
Public Enum SetLicenseFlags  
public enum class SetLicenseFlags   

Members
ValueMemberDescription
0x00000001LicenseIsFileSpecifies that the license parameter is a path to the license file. Absence of this flag indicates that the license parameter is a string containing the license data.
0x00000002KeyIsFileSpecifies that the key parameter is a path to a key file. Absence of this flag indicates that the key parameter is a string containing the key data.
0x00000004OverwriteSpecifies that the previous license state should be overwritten. Absence of this flag indicates that an existing valid license should not be overwritten.

Remarks

Combine the values by using a bitwise OR.

Example
C#
VB
using Leadtools; 
using Leadtools.MediaStreaming; 
 
 
public class LicenseHolder 
{ 
   protected LicenseManager m_licmgr; 
   protected bool m_service; 
   protected bool m_verbose; 
   protected string m_title; 
 
   public LicenseHolder(bool verbose, string title, bool service) 
   { 
      m_service = service; 
      m_verbose = verbose; 
      m_title = title; 
   } 
   ~LicenseHolder() 
   { 
 
   } 
 
   protected bool IsDisplayEnabled() 
   { 
      return (m_verbose && !m_service); 
   } 
 
   protected DialogResult DisplayLicenseError(string message) 
   { 
      return MessageBox.Show(message, m_title, MessageBoxButtons.OK, MessageBoxIcon.Error); 
   } 
 
   public void LoadLicenseManager() 
   { 
      try 
      { 
         if (m_licmgr == null) 
         { 
            m_licmgr = new LicenseManager(); 
         } 
      } 
      catch (System.Exception ex) 
      { 
         if (IsDisplayEnabled()) 
         { 
            DisplayLicenseError("Can't instantiate LEAD Media Streaming License Manager"); 
         } 
 
         throw ex; 
      } 
   } 
 
   public void SetLicense(string license, string key, SetLicenseFlags flags) 
   { 
      LoadLicenseManager(); 
 
      try 
      { 
         // Sets the license for the calling application 
         m_licmgr.SetLicense(license, key, (int)flags); 
      } 
      catch (System.Exception ex) 
      { 
         if (IsDisplayEnabled()) 
         { 
            DisplayLicenseError("Your license file is missing, invalid or expired. The LEAD Media Streaming Library will not function. Please contact LEAD Sales for information on obtaining a valid license."); 
            Process.Start("https://www.leadtools.com/downloads/evaluation-form.asp?evallicenseonly=true"); 
         } 
 
         throw ex; 
      } 
   } 
   public void UnloadLicenseManager() 
   { 
      m_licmgr.Dispose(); 
      m_licmgr = null; 
   } 
 
} 
 
 
public Server _server = null; 
public bool _result = false; 
 
public void LicenseHolderExample() 
{ 
   try 
   { 
      // create an instance of the LicenseHolder class 
      LicenseHolder holder = new LicenseHolder(true, "Leadtools MediaStreaming Server", false); 
 
      // set the license 
      holder.SetLicense("%ltmsAppFolder%\\LEADTOOLS.LIC", "%ltmsAppFolder%\\LEADTOOLS.LIC.KEY", SetLicenseFlags.LicenseIsFile | SetLicenseFlags.KeyIsFile); 
 
      // create an instance of the server object 
      _server = new Leadtools.MediaStreaming.Server(); 
 
      // start the server 
      _server.Start(); 
 
      // confirm the running state for demonstration purposes 
      if (_server.State == State.Started) 
      { 
         // display a message that the server is running and wait for OK 
         MessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information); 
      } 
 
      // stop the server 
      _server.Stop(); 
 
      // unload the license 
      holder.UnloadLicenseManager(); 
 
      _result = true; 
   } 
   catch (Exception) 
   { 
      _result = false; 
   } 
} 
Imports Leadtools 
Imports Leadtools.MediaStreaming 
 
 
Public Class LicenseHolder 
   Protected m_licmgr As LicenseManager 
   Protected m_service As Boolean 
   Protected m_verbose As Boolean 
   Protected m_title As String 
 
   Public Sub New(ByVal verbose As Boolean, ByVal title As String, ByVal service As Boolean) 
      m_service = service 
      m_verbose = verbose 
      m_title = title 
   End Sub 
   Protected Overrides Sub Finalize() 
 
   End Sub 
 
   Protected Function IsDisplayEnabled() As Boolean 
      Return (m_verbose AndAlso (Not m_service)) 
   End Function 
 
   Protected Function DisplayLicenseError(ByVal message As String) As DialogResult 
      Return MessageBox.Show(message, m_title, MessageBoxButtons.OK, MessageBoxIcon.Error) 
   End Function 
 
   Public Sub LoadLicenseManager() 
      Try 
         If m_licmgr Is Nothing Then 
            m_licmgr = New LicenseManager() 
         End If 
      Catch ex As System.Exception 
         If IsDisplayEnabled() Then 
            DisplayLicenseError("Can't instantiate LEAD Media Streaming License Manager") 
         End If 
 
         Throw ex 
      End Try 
   End Sub 
 
   Public Sub SetLicense(ByVal license As String, ByVal key As String, ByVal flags As SetLicenseFlags) 
      LoadLicenseManager() 
 
      Try 
         ' Sets the license for the calling application 
         m_licmgr.SetLicense(license, key, CInt(flags)) 
      Catch ex As System.Exception 
         If IsDisplayEnabled() Then 
            DisplayLicenseError("Your license file is missing, invalid or expired. The LEAD Media Streaming Library will not function. Please contact LEAD Sales for information on obtaining a valid license.") 
            Process.Start("https://www.leadtools.com/downloads/evaluation-form.asp?evallicenseonly=true") 
         End If 
 
         Throw ex 
      End Try 
   End Sub 
   Public Sub UnloadLicenseManager() 
      m_licmgr.Dispose() 
      m_licmgr = Nothing 
   End Sub 
 
End Class 
 
 
Public _server As Server = Nothing 
Public _result As Boolean = False 
 
Public Sub LicenseHolderExample() 
   Try 
      ' create an instance of the LicenseHolder class 
      Dim holder As LicenseHolder = New LicenseHolder(True, "Leadtools MediaStreaming Server", False) 
 
      ' set the license 
      holder.SetLicense("%ltmsAppFolder%\LEADTOOLS.LIC", "%ltmsAppFolder%\LEADTOOLS.LIC.KEY", SetLicenseFlags.LicenseIsFile Or SetLicenseFlags.KeyIsFile) 
 
      ' create an instance of the server object 
      _server = New Leadtools.MediaStreaming.Server() 
 
      ' start the server 
      _server.Start() 
 
      ' confirm the running state for demonstration purposes 
      If _server.State = State.Started Then 
         ' display a message that the server is running and wait for OK 
         MessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information) 
      End If 
 
      ' stop the server 
      _server.Stop() 
 
      ' unload the license 
      holder.UnloadLicenseManager() 
 
      _result = True 
   Catch e1 As Exception 
      _result = False 
   End Try 
End Sub 

Requirements

Target Platforms

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.MediaStreaming Assembly