Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, October 31, 2017 10:34:08 AM(UTC)
Christopher Thompson

Groups: Tech Support, Administrators
Posts: 60

Was thanked: 2 time(s) in 2 post(s)

There are several overloads available for users to be able to set up the license and key files.
Below are a few ways to do this:

The first way is by using two strings: RasterSupport.SetLicense(string, string)
There are several ways to set a string variable in C# and VB so we have included a couple of different examples depending on your personal preference.
C#
Code:

using Leadtools;
using Leadtools.Codecs;

namespace SetLicense_console_cs
{
	class Program
	{
		static void Main(string[] args)
		{
			//SetLicense(string, string) Method
			string licenseFilePath = @"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC"; //Your .LIC file path here
			string developerKey = System.IO.File.ReadAllText(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC.key"); //Your .KEY file path here

			RasterSupport.SetLicense(licenseFilePath, developerKey);

			//Tests to see if license supports a particular type
			bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document);

			if (isLocked)
				Console.WriteLine("Document support is locked");
			else
				Console.WriteLine("Document support is unlocked");

			Console.ReadKey();
		}
	}
}


VB
Code:

Imports Leadtools
Imports Leadtools.Codecs

Module Module1

    Sub Main()

        'SetLicense(string, string) Method
        Dim licenseFilePath As String = "C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC" 'Your .LIC file path here
        Dim developerKey As String = System.IO.File.ReadAllText("C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC.key") 'Your .KEY file path here
        RasterSupport.SetLicense(licenseFilePath, developerKey)

        Dim isLocked As Boolean = RasterSupport.IsLocked(RasterSupportType.Document)

        If (isLocked) Then
            Console.WriteLine("Document support is locked")
        Else
            Console.WriteLine("Document support is unlocked")
        End If

        Console.ReadLine()

    End Sub

End Module


C#
Code:

using Leadtools;
using Leadtools.Codecs;

namespace SetLicense_console_cs
{
	class Program
	{
		static void Main(string[] args)
		{
			//SetLicense(string, string) Method
			string licenseFilePath = @"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC"; //Your .LIC file path here
			string developerKey = ""; //Copy your key contents to this string location

			RasterSupport.SetLicense(licenseFilePath, developerKey);

			//Tests to see if license supports a particular type
			bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document);

			if (isLocked)
				Console.WriteLine("Document support is locked");
			else
				Console.WriteLine("Document support is unlocked");

			Console.ReadKey();
		}
	}
}


VB
Code:

Imports Leadtools
Imports Leadtools.Codecs

Module Module1

    Sub Main()

        'SetLicense(string, string) Method
        Dim licenseFilePath As String = "C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC" 'Your .LIC file path
        Dim developerKey As String = "" 'Copy your key contents to this string location
        RasterSupport.SetLicense(licenseFilePath, developerKey)

        Dim isLocked As Boolean = RasterSupport.IsLocked(RasterSupportType.Document)

        If (isLocked) Then
            Console.WriteLine("Document support is locked")
        Else
            Console.WriteLine("Document support is unlocked")
        End If

        Console.ReadLine()

    End Sub

End Module



The Next way is by using a stream and a string: RasterSupport.SetLicense(Stream, string)

C#
Code:

using Leadtools;
using Leadtools.Codecs;

namespace SetLicense_console_cs
{
	class Program
	{
		static void Main(string[] args)
		{
			//SetLicense(Stream, string) Method
			Stream licenseStream = File.OpenRead(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC");
			string developerKey = ""; //Copy your key contents to this string location

			RasterSupport.SetLicense(licenseStream, developerKey);

			//Tests to see if license supports a particular type
			bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document);

			if (isLocked)
				Console.WriteLine("Document support is locked");
			else
				Console.WriteLine("Document support is unlocked");

			Console.ReadKey();
		}
	}
}


VB
Code:

Imports Leadtools
Imports Leadtools.Codecs

Module Module1

    Sub Main()

        'SetLicense(Stream, string) Method
        Dim licenseStream As FileStream = File.OpenRead("C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC")
        Dim developerKey As String = "" 'Copy your key contents to this string location

        RasterSupport.SetLicense(licenseStream, developerKey)

        Dim isLocked As Boolean = RasterSupport.IsLocked(RasterSupportType.Document)

        If (isLocked) Then
            Console.WriteLine("Document support is locked")
        Else
            Console.WriteLine("Document support is unlocked")
        End If

        Console.ReadLine()

    End Sub

End Module


The Last way is by using bytes and a string: RasterSupport.SetLicense(Byte[], string)

C#
Code:

using Leadtools;
using Leadtools.Codecs;

namespace SetLicense_console_cs
{
	class Program
	{
		static void Main(string[] args)
		{
			//SetLicense(Byte[], String) Method
			byte[] licenseBuffer = System.IO.File.ReadAllBytes(@"C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC"); //Your .LIC file path here
			string developerKey = ""; //Copy your key contents to this string location

			RasterSupport.SetLicense(licenseBuffer, developerKey);

			//Tests to see if license supports a particular type
			bool isLocked = RasterSupport.IsLocked(RasterSupportType.Document);

			if (isLocked)
				Console.WriteLine("Document support is locked");
			else
				Console.WriteLine("Document support is unlocked");

			Console.ReadKey();
		}
	}
}



VB
Code:

Imports Leadtools
Imports Leadtools.Codecs

Module Module1

    Sub Main()

        'SetLicense(Byte[], String) Method
        Dim licenseBuffer = System.IO.File.ReadAllBytes("C:\LEADTOOLS 20\Support\Common\License\LEADTOOLS.LIC") 'Your .LIC file path here
        Dim developerKey As String = "" 'Copy your key contents to this string location

        RasterSupport.SetLicense(licenseBuffer, developerKey)

        Dim isLocked As Boolean = RasterSupport.IsLocked(RasterSupportType.Document)

        If (isLocked) Then
            Console.WriteLine("Document support is locked")
        Else
            Console.WriteLine("Document support is unlocked")
        End If

        Console.ReadLine()

    End Sub

End Module

Edited by moderator Friday, March 22, 2019 8:09:17 AM(UTC)  | Reason: Updated v20 license paths (and VB variable names)

Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2019, Yet Another Forum.NET
This page was generated in 0.088 seconds.