mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
The Tools.EnvironmentInfo class didn't need to exist. Replace a single call to it with Environment.Is64BitProcess
This commit is contained in:
@@ -28,7 +28,7 @@ namespace mRemoteNG.App.Info
|
||||
var details = new List<string>();
|
||||
details.Add("compatible");
|
||||
details.Add(OSVersion.Platform == PlatformID.Win32NT ? $"Windows NT {OSVersion.Version.Major}.{OSVersion.Version.Minor}": OSVersion.VersionString);
|
||||
if (Tools.EnvironmentInfo.IsWow64)
|
||||
if (Is64BitProcess)
|
||||
{
|
||||
details.Add("WOW64");
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
|
||||
namespace mRemoteNG.Tools
|
||||
{
|
||||
public class EnvironmentInfo
|
||||
{
|
||||
public static bool IsWow64
|
||||
{
|
||||
get
|
||||
{
|
||||
Win32.IsWow64ProcessDelegate isWow64ProcessDelegate = GetIsWow64ProcessDelegate();
|
||||
if (isWow64ProcessDelegate == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isWow64Process = false;
|
||||
bool result = Convert.ToBoolean(isWow64ProcessDelegate.Invoke(Process.GetCurrentProcess().Handle, ref isWow64Process));
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return isWow64Process;
|
||||
}
|
||||
}
|
||||
|
||||
private static Win32.IsWow64ProcessDelegate GetIsWow64ProcessDelegate()
|
||||
{
|
||||
IntPtr moduleHandle = Win32.LoadLibrary("kernel32");
|
||||
if (moduleHandle == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IntPtr functionPointer = Win32.GetProcAddress(moduleHandle, "IsWow64Process");
|
||||
if (functionPointer == IntPtr.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Win32.IsWow64ProcessDelegate)Marshal.GetDelegateForFunctionPointer(functionPointer, typeof(Win32.IsWow64ProcessDelegate));
|
||||
}
|
||||
|
||||
protected class Win32
|
||||
{
|
||||
// ReSharper disable InconsistentNaming
|
||||
[DllImport("kernel32", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern IntPtr LoadLibrary([In(), MarshalAs(UnmanagedType.LPTStr)]string lpFileName);
|
||||
|
||||
[DllImport("kernel32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)]
|
||||
public static extern IntPtr GetProcAddress([In()]IntPtr hModule, [In(), MarshalAs(UnmanagedType.LPStr)]string lpProcName);
|
||||
|
||||
public delegate bool IsWow64ProcessDelegate([In()]IntPtr hProcess, ref bool Wow64Process);
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,6 @@
|
||||
<Compile Include="Settings.cs" />
|
||||
<Compile Include="Tools\Authenticode.cs" />
|
||||
<Compile Include="Tools\EnumWindows.cs" />
|
||||
<Compile Include="Tools\EnvironmentInfo.cs" />
|
||||
<Compile Include="Tools\PropertyGridCommandSite.cs" />
|
||||
<Compile Include="Connection\PuttySessionInfo.cs" />
|
||||
<Compile Include="Tree\Root\RootPuttySessionsNodeInfo.cs" />
|
||||
|
||||
Reference in New Issue
Block a user