make GetProcessExecuteable obsolete
-> use Environment.GetProcessPath instead
This commit is contained in:
@@ -1,21 +1,15 @@
|
|||||||
using Pilz.Runtime;
|
using Pilz.Runtime;
|
||||||
using Pilz.Win32.Native;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Pilz.Win32;
|
namespace Pilz.Win32;
|
||||||
|
|
||||||
public static class NativeTools
|
public static class NativeTools
|
||||||
{
|
{
|
||||||
static readonly int MAX_PATH = 255;
|
[Obsolete("Use \"Environment.ProcessPath\" instead.")]
|
||||||
|
|
||||||
public static string GetExecutablePath(bool checkRealOS = false)
|
public static string GetExecutablePath(bool checkRealOS = false)
|
||||||
{
|
{
|
||||||
if (RuntimeInformationsEx.IsOSPlatform(OSType.Windows, checkRealOS))
|
if (RuntimeInformationsEx.IsOSPlatform(OSType.Windows, checkRealOS))
|
||||||
{
|
return Environment.ProcessPath;
|
||||||
var sb = new StringBuilder(MAX_PATH);
|
return Process.GetCurrentProcess().MainModule.FileName;
|
||||||
Kernel32.GetModuleFileName(IntPtr.Zero, sb, MAX_PATH);
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
|
||||||
return Environment.ProcessPath; //Process.GetCurrentProcess().MainModule.FileName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user