资源简介
c#仿Windows任务管理器,显示应用程序,进程,性能(CPU使用情况、内存使用情况、硬盘所用及剩余空间)

代码片段和文件信息
using System;
using System.IO;
using System.Collections;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
///Download by http://www.newxing.com
namespace Lemony.SystemInfo
{
///
/// CustomMarshaler class implementation.
///
public abstract class CustomMarshaler
{
#region Fields
// The internal buffer
internal byte[] data;
private MemoryStream stream;
private BinaryReader binReader;
private BinaryWriter binWriter;
#endregion
#region constructors
public CustomMarshaler()
{
}
#endregion
#region public methods
public void Deserialize()
{
if (data != null)
{
if (binReader != null)
{
binReader.Close();
stream.Close();
}
// Create a steam from byte array
stream = new MemoryStream(data);
binReader = new BinaryReader(stream System.Text.Encoding.Unicode);
ReadFromStream(binReader);
binReader.Close();
}
}
public void Serialize()
{
if (data != null)
{
stream = new MemoryStream(data);
binWriter = new BinaryWriter(stream System.Text.Encoding.Unicode);
WriteToStream(binWriter);
binWriter.Close();
}
}
public int GetSize()
{
int size = 0;
FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
foreach (FieldInfo field in fields )
{
if (field.FieldType.IsArray)
{
size += GetFieldSize(field);
}
else if (field.FieldType == typeof(string))
{
size += GetFieldSize(field)*2;
}
else if (field.FieldType.IsPrimitive)
{
size += Marshal.SizeOf(field.FieldType);
}
}
return size;
}
#endregion
#region properties
public byte[] ByteArray
{
get
{
return data;
}
}
#endregion
#region virtual and protected methods
public virtual void ReadFromStream(BinaryReader reader)
{
object[] param = null;
// Get all public fields
FieldInfo[] fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance);
// Loop through the fields
foreach(FieldInfo field in fields)
{
// Retrieve the read method from ReadMethods hashtable
MethodInfo method = (MethodInfo)MarshallingMethods.ReadMethods[field.FieldType];
if (field.FieldType.IsArray)
{
Type element = field.FieldType.GetElementType();
if (element.IsValueType && element.IsPrimitive)
{
if ((element == typeof(char)) || element == typeof(byte))
{
param = new object[1];
param[0] = GetFieldSize(field);
field.SetValue(this method.Invoke(reader param));
}
else // any other value type array
{
param = new object[2];
param[0] = reader;
param[1] = GetFieldSize(field);
field.SetValue(this method.Invoke(null param))
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1162 2007-03-29 09:08 www.NewXing.com\Test\Properties\AssemblyInfo.cs
文件 1321 2007-03-29 09:04 www.NewXing.com\SystemInfo\Properties\AssemblyInfo.cs
文件 14965 2010-11-12 01:07 www.NewXing.com\SystemInfo\CustomtMarshaler.cs
文件 947 2010-11-12 01:07 www.NewXing.com\SystemInfo\DiskInfo.cs
文件 8826 2007-03-29 15:58 www.NewXing.com\Test\frmProcess.cs
文件 26464 2007-03-29 15:58 www.NewXing.com\Test\frmProcess.designer.cs
文件 924 2010-11-12 01:07 www.NewXing.com\SystemInfo\IpInfo.cs
文件 4181 2007-03-29 09:11 www.NewXing.com\Test\LineChart.cs
文件 1599 2007-03-29 09:12 www.NewXing.com\Test\LineChart.Designer.cs
文件 2039 2010-11-12 01:07 www.NewXing.com\SystemInfo\MIB_IFROW.cs
文件 596 2010-11-12 01:07 www.NewXing.com\SystemInfo\MIB_IFTABLE.cs
文件 3464 2010-11-12 01:07 www.NewXing.com\SystemInfo\NetInfo.cs
文件 1559 2010-11-12 01:07 www.NewXing.com\SystemInfo\ProcessInfo.cs
文件 468 2007-03-29 09:14 www.NewXing.com\Test\Program.cs
文件 2862 2007-03-29 09:08 www.NewXing.com\Test\Properties\Resources.Designer.cs
文件 1087 2007-03-29 09:08 www.NewXing.com\Test\Properties\Settings.Designer.cs
文件 17348 2010-11-12 01:08 www.NewXing.com\SystemInfo\SystemInfo.cs
文件 2299 2007-03-29 09:09 www.NewXing.com\SystemInfo\SystemInfo.csproj
文件 3816 2007-03-29 15:57 www.NewXing.com\Test\Test.csproj
文件 6774 2007-03-29 15:58 www.NewXing.com\Test\frmProcess.resx
文件 5814 2007-01-08 17:21 www.NewXing.com\Test\LineChart.resx
文件 5612 2007-03-29 09:08 www.NewXing.com\Test\Properties\Resources.resx
文件 249 2007-03-29 09:08 www.NewXing.com\Test\Properties\Settings.settings
文件 1385 2007-03-29 09:09 www.NewXing.com\SystemInfo.sln
..A..H. 24064 2007-04-11 09:18 www.NewXing.com\SystemInfo.suo
目录 0 2007-04-06 15:59 www.NewXing.com\SystemInfo\Properties
目录 0 2007-04-06 15:59 www.NewXing.com\Test\Properties
目录 0 2007-04-06 15:59 www.NewXing.com\bin
目录 0 2007-04-06 15:59 www.NewXing.com\SystemInfo
目录 0 2007-04-06 15:59 www.NewXing.com\Test
............此处省略3个文件信息
相关资源
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
评论
共有 条评论