22 lines
588 B
C#
22 lines
588 B
C#
using Pilz.Runtime;
|
|
using Pilz.Win32.Native;
|
|
using System.Text;
|
|
|
|
namespace Pilz.Win32;
|
|
|
|
public static class NativeTools
|
|
{
|
|
static readonly int MAX_PATH = 255;
|
|
|
|
public static string GetExecutablePath(bool checkRealOS = false)
|
|
{
|
|
if (RuntimeInformationsEx.IsOSPlatform(OSType.Windows, checkRealOS))
|
|
{
|
|
var sb = new StringBuilder(MAX_PATH);
|
|
Kernel32.GetModuleFileName(IntPtr.Zero, sb, MAX_PATH);
|
|
return sb.ToString();
|
|
}
|
|
return Environment.ProcessPath; //Process.GetCurrentProcess().MainModule.FileName;
|
|
}
|
|
}
|