make GetProcessExecuteable obsolete

-> use Environment.GetProcessPath instead
This commit is contained in:
Pilzinsel64
2024-09-02 15:43:56 +02:00
parent 5a6f8e207e
commit 2c85125338

View File

@@ -1,21 +1,15 @@
using Pilz.Runtime;
using Pilz.Win32.Native;
using System.Text;
using System.Diagnostics;
namespace Pilz.Win32;
public static class NativeTools
{
static readonly int MAX_PATH = 255;
[Obsolete("Use \"Environment.ProcessPath\" instead.")]
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;
return Environment.ProcessPath;
return Process.GetCurrentProcess().MainModule.FileName;
}
}