API 함수를 사용하여 시스템 정보 얻기
<HTML>
<HEAD>
<title>SystemInfo</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<colgroup>
<col width="50%">
<col width="50%">
</colgroup>
<table width="100%">
<tr>
<td bgcolor="#99ccff">Window :</td>
<td bgcolor="#99ccff"> :</td>
</tr>
<tr>
<td>
<asp:Label id="WindowsDirectory" runat="server">WindowsDirectory</asp:Label></td>
<td>
<asp:Label id="Date" runat="server">Date</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="SystemDirectory" runat="server">SystemDirectoryLabel</asp:Label></td>
<td>
<asp:Label id="Time" runat="server">Time</asp:Label></td>
</tr>
<tr>
<td bgcolor="#99ccff"> :</td>
<td bgcolor="#99ccff">CUP :</td>
</tr>
<tr>
<td>
<asp:Label id="MemoryLoad" runat="server">MemoryLoad</asp:Label></td>
<td>
<asp:Label id="NumberOfProcessors" runat="server">NumberOfProcessorsLabel</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="TotalPhys" runat="server">TotalPhys</asp:Label></td>
<td>
<asp:Label id="ProcessorType" runat="server">ProcessorTypeLabel</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="AvailPhys" runat="server">AvailPhys</asp:Label></td>
<td>
<asp:Label id="ProcessorLevel" runat="server">ProcessorLevelLabel</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="TotalPageFile" runat="server">TotalPageFile</asp:Label></td>
<td>
<asp:Label id="OemId" runat="server">OemIdLabel</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="AvailPageFile" runat="server">AvailPageFile</asp:Label></td>
<td>
<asp:Label id="PageSize" runat="server">PageSize</asp:Label></td>
</tr>
<tr>
<td>
<asp:Label id="TotalVirtual" runat="server">TotalVirtualLabel</asp:Label></td>
<td></td>
</tr>
<tr>
<td>
<asp:Label id="AvailVirtual" runat="server">AvailVirtualLabel</asp:Label></td>
<td></td>
</tr>
</table>
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 752px; POSITION: absolute; TOP: 304px" runat="server"
Text=" "></asp:Button>
</form>
</body>
</HTML>
public class SystemInfo : System.Web.UI.Page
{
//
//using System.Runtime.InteropServices;
//using System.Text;
protected System.Web.UI.WebControls.Label WindowsDirectory;
protected System.Web.UI.WebControls.Label SystemDirectory;
protected System.Web.UI.WebControls.Label NumberOfProcessors;
protected System.Web.UI.WebControls.Label ProcessorType;
protected System.Web.UI.WebControls.Label ProcessorLevel;
protected System.Web.UI.WebControls.Label OemId;
protected System.Web.UI.WebControls.Label PageSize;
protected System.Web.UI.WebControls.Label MemoryLoad;
protected System.Web.UI.WebControls.Label TotalPhys;
protected System.Web.UI.WebControls.Label AvailPhys;
protected System.Web.UI.WebControls.Label TotalPageFile;
protected System.Web.UI.WebControls.Label AvailPageFile;
protected System.Web.UI.WebControls.Label TotalVirtual;
protected System.Web.UI.WebControls.Label AvailVirtual;
protected System.Web.UI.WebControls.Label Date;
protected System.Web.UI.WebControls.Label Time;
protected System.Web.UI.WebControls.Button Button1;
// API , System.Runtime.InteropServices 。
// ,"DllImport" , DLL , DLL ;
//"kernel32" ;"public" ;
//"static" , ;
//"extern" , DllImport "extern"
[DllImport("kernel32")]
public static extern void GetWindowsDirectory(StringBuilder WinDir,int count);
[DllImport("kernel32")]
public static extern void GetSystemDirectory(StringBuilder SysDir,int count);
[DllImport("kernel32")]
public static extern void GetSystemInfo(ref CPU_INFO cpuinfo);
[DllImport("kernel32")]
public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo);
[DllImport("kernel32")]
public static extern void GetSystemTime(ref SYSTEMTIME_INFO stinfo);
// CPU
[StructLayout(LayoutKind.Sequential)]
public struct CPU_INFO
{
public uint dwOemId;
public uint dwPageSize;
public uint lpMinimumApplicationAddress;
public uint lpMaximumApplicationAddress;
public uint dwActiveProcessorMask;
public uint dwNumberOfProcessors;
public uint dwProcessorType;
public uint dwAllocationGranularity;
public uint dwProcessorLevel;
public uint dwProcessorRevision;
}
//
[StructLayout(LayoutKind.Sequential)]
public struct MEMORY_INFO
{
public uint dwLength;
public uint dwMemoryLoad;
public uint dwTotalPhys;
public uint dwAvailPhys;
public uint dwTotalPageFile;
public uint dwAvailPageFile;
public uint dwTotalVirtual;
public uint dwAvailVirtual;
}
//
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEMTIME_INFO
{
public ushort wYear;
public ushort wMonth;
public ushort wDayOfWeek;
public ushort wDay;
public ushort wHour;
public ushort wMinute;
public ushort wSecond;
public ushort wMilliseconds;
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
Web Form Designer generated code#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/**//// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
// GetWindowsDirectory GetSystemDirectory Windows
const int nChars = 128;
StringBuilder Buff = new StringBuilder(nChars);
GetWindowsDirectory(Buff,nChars);
WindowsDirectory.Text = "Windows :"+Buff.ToString();
GetSystemDirectory(Buff,nChars);
SystemDirectory.Text = " :"+Buff.ToString();
// GetSystemInfo CPU
CPU_INFO CpuInfo;
CpuInfo = new CPU_INFO();
GetSystemInfo(ref CpuInfo);
NumberOfProcessors.Text = " "+CpuInfo.dwNumberOfProcessors.ToString()+" CPU";
ProcessorType.Text = "CPU "+CpuInfo.dwProcessorType.ToString();
ProcessorLevel.Text = "CPU "+CpuInfo.dwProcessorLevel.ToString();
OemId.Text = "CPU OEM ID "+CpuInfo.dwOemId.ToString();
PageSize.Text = "CPU "+CpuInfo.dwPageSize.ToString();
// GlobalMemoryStatus
MEMORY_INFO MemInfo;
MemInfo = new MEMORY_INFO();
GlobalMemoryStatus(ref MemInfo);
MemoryLoad.Text = MemInfo.dwMemoryLoad.ToString()+"% ";
TotalPhys.Text = " "+MemInfo.dwTotalPhys.ToString()+" ";
AvailPhys.Text = " "+MemInfo.dwAvailPhys.ToString()+" ";
TotalPageFile.Text = " "+MemInfo.dwTotalPageFile.ToString()+" ";
AvailPageFile.Text = " "+MemInfo.dwAvailPageFile.ToString()+" ";
TotalVirtual.Text = " "+MemInfo.dwTotalVirtual.ToString()+" ";
AvailVirtual.Text = " "+MemInfo.dwAvailVirtual.ToString()+" ";
// GetSystemTime
SYSTEMTIME_INFO StInfo;
StInfo = new SYSTEMTIME_INFO();
GetSystemTime(ref StInfo);
Date.Text = StInfo.wYear.ToString()+" "+StInfo.wMonth.ToString()+" "+StInfo.wDay.ToString()+" ";
Time.Text = (StInfo.wHour+8).ToString()+" "+StInfo.wMinute.ToString()+" "+StInfo.wSecond.ToString()+" ";
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Application Development in WebOSDevelop applications in WebOS Recognize the abstract class Application The operating system accepts classes that impleme...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.