Sets the license for the calling application.
Public Sub SetLicense( _ByVal license As String, _ByVal key As String, _ByVal flags As Integer _)
license
String containing the license or the path to the license file.
key
String containing the key or the path to the key file.
flags
Flags that specify which type of operation to perform. It is a bitwise OR of the SetLicenseFlags Enumeration Constants.
This method will set the license for the entire application, and is only required to be called once. If the library is already licensed, any additional calls to this function will be ignored, unless Overwrite is specified.
If the method fails, an error is raised. For more information, refer to the Error Codes.
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 applicationm_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 classLicenseHolder holder = new LicenseHolder(true, "Leadtools MediaStreaming Server", false);// set the licenseholder.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 purposesif (_server.State == State.Started){// display a message that the server is running and wait for OKMessageBox.Show("The server has started. Press OK to stop.", "LEADTOOLS Media Streaming Examples", MessageBoxButtons.OK, MessageBoxIcon.Information);}// stop the server_server.Stop();// unload the licenseholder.UnloadLicenseManager();_result = true;}catch (Exception){_result = false;}}
Imports LeadtoolsImports Leadtools.MediaStreamingPublic Class LicenseHolderProtected m_licmgr As LicenseManagerProtected m_service As BooleanProtected m_verbose As BooleanProtected m_title As StringPublic Sub New(ByVal verbose As Boolean, ByVal title As String, ByVal service As Boolean)m_service = servicem_verbose = verbosem_title = titleEnd SubProtected Overrides Sub Finalize()End SubProtected Function IsDisplayEnabled() As BooleanReturn (m_verbose AndAlso (Not m_service))End FunctionProtected Function DisplayLicenseError(ByVal message As String) As DialogResultReturn MessageBox.Show(message, m_title, MessageBoxButtons.OK, MessageBoxIcon.Error)End FunctionPublic Sub LoadLicenseManager()TryIf m_licmgr Is Nothing Thenm_licmgr = New LicenseManager()End IfCatch ex As System.ExceptionIf IsDisplayEnabled() ThenDisplayLicenseError("Can't instantiate LEAD Media Streaming License Manager")End IfThrow exEnd TryEnd SubPublic Sub SetLicense(ByVal license As String, ByVal key As String, ByVal flags As SetLicenseFlags)LoadLicenseManager()Try' Sets the license for the calling applicationm_licmgr.SetLicense(license, key, CInt(flags))Catch ex As System.ExceptionIf IsDisplayEnabled() ThenDisplayLicenseError("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 IfThrow exEnd TryEnd SubPublic Sub UnloadLicenseManager()m_licmgr.Dispose()m_licmgr = NothingEnd SubEnd ClassPublic _server As Server = NothingPublic _result As Boolean = FalsePublic Sub LicenseHolderExample()Try' create an instance of the LicenseHolder classDim holder As LicenseHolder = New LicenseHolder(True, "Leadtools MediaStreaming Server", False)' set the licenseholder.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 purposesIf _server.State = State.Started Then' display a message that the server is running and wait for OKMessageBox.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 licenseholder.UnloadLicenseManager()_result = TrueCatch e1 As Exception_result = FalseEnd TryEnd Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
