資源簡介
任務管理器,按著系統來的, 歡迎大家下載

代碼片段和文件信息
using?System;
using?System.IO;
using?System.Collections;
using?System.Reflection;
using?System.Runtime.InteropServices;
using?System.Threading;
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));?
}
}
else?//?array
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????23552??2013-09-25?11:39??C#?任務管理器\SystemInfo\bin\Lemony.SystemInfo.dll
?????文件??????77312??2013-09-25?11:39??C#?任務管理器\SystemInfo\bin\Lemony.SystemInfo.pdb
?????文件??????24064??2013-09-27?20:14??C#?任務管理器\SystemInfo\bin\Test.exe
?????文件??????50688??2013-09-27?20:14??C#?任務管理器\SystemInfo\bin\Test.pdb
?????文件??????14328??2013-09-27?23:16??C#?任務管理器\SystemInfo\bin\Test.vshost.exe
?????文件????????490??2009-06-11?05:14??C#?任務管理器\SystemInfo\bin\Test.vshost.exe.manifest
?????文件??????14926??2007-03-29?09:06??C#?任務管理器\SystemInfo\SystemInfo\CustomtMarshaler.cs
?????文件????????908??2007-03-29?09:06??C#?任務管理器\SystemInfo\SystemInfo\DiskInfo.cs
?????文件????????885??2007-03-29?09:06??C#?任務管理器\SystemInfo\SystemInfo\IpInfo.cs
?????文件???????2000??2007-03-29?09:07??C#?任務管理器\SystemInfo\SystemInfo\MIB_IFROW.cs
?????文件????????557??2007-03-29?09:07??C#?任務管理器\SystemInfo\SystemInfo\MIB_IFTABLE.cs
?????文件???????3427??2007-03-29?09:07??C#?任務管理器\SystemInfo\SystemInfo\NetInfo.cs
?????文件??????23552??2013-09-25?11:39??C#?任務管理器\SystemInfo\SystemInfo\obj\Debug\Lemony.SystemInfo.dll
?????文件??????77312??2013-09-25?11:39??C#?任務管理器\SystemInfo\SystemInfo\obj\Debug\Lemony.SystemInfo.pdb
?????文件????????830??2013-09-25?01:08??C#?任務管理器\SystemInfo\SystemInfo\obj\Debug\SystemInfo.csproj.FileListAbsolute.txt
?????文件???????1519??2013-09-25?11:36??C#?任務管理器\SystemInfo\SystemInfo\ProcessInfo.cs
?????文件???????1321??2007-03-29?09:04??C#?任務管理器\SystemInfo\SystemInfo\Properties\AssemblyInfo.cs
?????文件??????17310??2013-09-25?01:05??C#?任務管理器\SystemInfo\SystemInfo\SystemInfo.cs
?????文件???????2470??2013-09-11?22:35??C#?任務管理器\SystemInfo\SystemInfo\SystemInfo.csproj
?????文件???????1386??2013-09-11?22:35??C#?任務管理器\SystemInfo\SystemInfo.sln
????..A..H.?????31744??2013-09-27?23:16??C#?任務管理器\SystemInfo\SystemInfo.suo
?????文件???????8981??2013-09-25?11:40??C#?任務管理器\SystemInfo\Test\frmProcess.cs
?????文件??????26464??2013-09-11?22:51??C#?任務管理器\SystemInfo\Test\frmProcess.designer.cs
?????文件???????6774??2013-09-12?00:18??C#?任務管理器\SystemInfo\Test\frmProcess.resx
?????文件???????4181??2013-09-11?22:53??C#?任務管理器\SystemInfo\Test\LineChart.cs
?????文件???????1599??2013-09-11?22:53??C#?任務管理器\SystemInfo\Test\LineChart.Designer.cs
?????文件???????5814??2013-09-11?22:53??C#?任務管理器\SystemInfo\Test\LineChart.resx
?????文件???????6223??2013-09-25?11:39??C#?任務管理器\SystemInfo\Test\obj\Debug\ResolveAssemblyReference.cache
?????文件???????4608??2013-09-25?00:33??C#?任務管理器\SystemInfo\Test\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
?????文件???????1414??2013-09-27?23:16??C#?任務管理器\SystemInfo\Test\obj\Debug\Test.csproj.FileListAbsolute.txt
............此處省略35個文件信息
- 上一篇:wpf DataGrid分組、排序、篩選
- 下一篇:c#實現四則混合運算
評論
共有 條評論