Skip to content

Commit

Permalink
Infrastructure Preparation 262
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Mar 8, 2024
1 parent 8e63790 commit cde827f
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Skylark" Version="3.1.3.4" />
<PackageReference Include="Skylark.Wing" Version="3.1.3.4" />
<PackageReference Include="Skylark.Wing" Version="3.1.3.5" />
</ItemGroup>
<ItemGroup>
<Compile Update="DuplicateWall.cs">
Expand Down
19 changes: 19 additions & 0 deletions src/Skylark.Wing/Helper/OperatingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Runtime.InteropServices;
using SEOST = Skylark.Enum.OperatingSystemType;

namespace Skylark.Wing.Helper
Expand Down Expand Up @@ -85,6 +86,24 @@ public static Version GetVersion()
return Environment.OSVersion.Version;
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public static string GetProcessorArchitecture()
{
return $"{Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")}";
}

/// <summary>
///
/// </summary>
/// <returns></returns>
public static Architecture GetProcessArchitecture()
{
return RuntimeInformation.ProcessArchitecture;
}

/// <summary>
///
/// </summary>
Expand Down
51 changes: 42 additions & 9 deletions src/Skylark.Wing/Helper/SystemInfo.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Runtime.InteropServices;
using System.Text;
using SE = Skylark.Exception;
using SWNM = Skylark.Wing.Native.Methods;

namespace Skylark.Wing.Helper
{
Expand Down Expand Up @@ -158,23 +158,56 @@ public static bool CheckWindowsNorKN()
return result;
}

/// <summary>
/// Total installed memory in Megabyte
/// </summary>
/// <returns></returns>
public static long GetTotalInstalledMemory()
{
SWNM.GetPhysicallyInstalledSystemMemory(out long memKb);

return memKb / 1024;
}

/// <summary>
///
/// </summary>
/// <param name="TotalMemoryInKilobytes"></param>
/// <returns></returns>
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetPhysicallyInstalledSystemMemory(out long TotalMemoryInKilobytes);
public static SWNM.SYSTEM_INFO GetSystemInfo()
{
SWNM.SYSTEM_INFO SystemInfo = new();

SWNM.GetNativeSystemInfo(ref SystemInfo);

return SystemInfo;
}

/// <summary>
/// Total installed memory in Megabyte
///
/// </summary>
/// <returns></returns>
public static long GetTotalInstalledMemory()
public static string GetSystemInfoArchitecture()
{
GetPhysicallyInstalledSystemMemory(out long memKb);
return memKb / 1024;
SWNM.SYSTEM_INFO SystemInfo = GetSystemInfo();

return SystemInfo.processorArchitecture switch
{
0 => "x86",
5 => "ARM",
6 => "IA64",
7 => "Alpha",
9 => "x64",
10 => "PPC",
12 => "ARM64",
13 => "SHX",
14 => "IA32_ON_WIN64",
15 => "AMD64_ON_WIN64",
16 => "WOW64",
17 => "IA64_ON_WIN64",
18 => "WOW64_IA64",
19 => "WOW64_ARM64",
_ => "Unknown",
};
}
}
}
30 changes: 28 additions & 2 deletions src/Skylark.Wing/Native/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public enum DWM_WINDOW_CORNER_PREFERENCE
public const int DWMWA_USE_IMMERSIVE_DARK_MODE = 20;

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType,
int cxDesired, int cyDesired, uint fuLoad);
public static extern IntPtr LoadImage(IntPtr hinst, string lpszName, uint uType, int cxDesired, int cyDesired, uint fuLoad);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int MessageBox(IntPtr hWnd, string text, string caption, uint type);
Expand Down Expand Up @@ -324,6 +323,22 @@ public enum RestartFlags
[DllImport("user32.dll")]
public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);

[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_INFO
{
public ushort processorArchitecture;
ushort reserved;
public uint pageSize;
public IntPtr minimumApplicationAddress;
public IntPtr maximumApplicationAddress;
public IntPtr activeProcessorMask;
public uint numberOfProcessors;
public uint processorType;
public uint allocationGranularity;
public ushort processorLevel;
public ushort processorRevision;
}

[StructLayout(LayoutKind.Sequential)]
public struct LASTINPUTINFO
{
Expand Down Expand Up @@ -1344,6 +1359,13 @@ public enum WM : uint

#endregion

/// <summary>
///
/// </summary>
/// <param name="lpSystemInfo"></param>
[DllImport("kernel32.dll")]
public static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo);

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

Expand All @@ -1360,6 +1382,10 @@ public enum WM : uint
[DllImport("kernel32.dll")]
public static extern bool SetProcessWorkingSetSize(IntPtr hProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);

[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetPhysicallyInstalledSystemMemory(out long TotalMemoryInKilobytes);

#region Window_Style
[DllImport("user32.dll")]
public static extern IntPtr GetMenu(IntPtr hWnd);
Expand Down
2 changes: 1 addition & 1 deletion src/Skylark.Wing/Skylark.Wing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// Website: www.Vegalya.com
// Created: 17.Jun.2023
// Changed: 08.Mar.2024
// Version: 3.1.3.5
// Version: 3.1.3.6
//
// |---------DO-NOT-REMOVE---------|

Expand Down
2 changes: 1 addition & 1 deletion src/Skylark.Wing/Skylark.Wing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<PropertyGroup>
<ApplicationIcon>Resources\Skylark.Wing.ico</ApplicationIcon>
<Version>3.1.3.5</Version>
<Version>3.1.3.6</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>Skylark.Wing</Title>
Expand Down

0 comments on commit cde827f

Please sign in to comment.