←Select platform

Platform Class

Summary

Provides information about the runtime platform. It contains a set of properties that can be used to determine the operating system, architecture, and other runtime-specific information.

Syntax

C#
Python
public static class Platform 
class Platform: 

Example

C#
using Leadtools; 
 
private static string GetLibraryPath() 
{ 
   var currentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
   string binFolderName = string.Empty; 
   var kernelName = string.Empty; 
   if (Platform.IsLinux) 
   { 
      binFolderName = Path.Combine("Lib", Platform.Is64Bit ? "x64" : "x86"); 
      kernelName = "libltkrn.so"; 
   } 
   else if (Platform.IsMacOS) 
   { 
      binFolderName = "Xcode/Frameworks/macOS/"; 
      kernelName = "Leadtools.framework"; 
   } 
   else 
   { 
      binFolderName = Path.Combine("CDLL", Platform.Is64Bit ? "x64" : "Win32"); 
      kernelName = Platform.Is64Bit ? "LtKrnx.dll" : "LtKrnu.dll"; 
   } 
 
   const int levels = 10; 
   for (var i = 0; i < levels; i++) 
   { 
      currentDir = Path.Combine(currentDir, ".."); 
 
      var path = Path.GetFullPath(Path.Combine(currentDir, "Bin", binFolderName, kernelName)); 
      if (Platform.IsMacOS && Directory.Exists(path) || File.Exists(path)) 
         return Path.GetDirectoryName(path); 
   } 
 
   throw new DllNotFoundException(kernelName); 
} 
 
public static void InitRuntime(string path) 
{ 
   if (string.IsNullOrEmpty(path)) 
      Platform.LibraryPath = Path.GetFullPath(GetLibraryPath()); 
   else 
      Platform.LibraryPath = path; 
} 

Requirements

Target Platforms

See Also

Platform Members

Leadtools Namespace

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

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.