資源簡介
C# 實現Windows任務管理器源代碼, 代碼完整,可以編譯運行

代碼片段和文件信息
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))
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????23552??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Lemony.SystemInfo.dll
?????文件??????67072??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Lemony.SystemInfo.pdb
?????文件??????24064??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Test.exe
?????文件??????38400??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Test.pdb
?????文件??????14328??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Test.vshost.exe
?????文件????????490??2009-06-11?05:14??C#?仿Windows任務管理器矯正版\www.NewXing.com\bin\Test.vshost.exe.manifest
?????文件??????14965??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\CustomtMarshaler.cs
?????文件????????947??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\DiskInfo.cs
?????文件????????924??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\IpInfo.cs
?????文件???????2039??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\MIB_IFROW.cs
?????文件????????596??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\MIB_IFTABLE.cs
?????文件???????3464??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\NetInfo.cs
?????文件??????23552??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\obj\Debug\Lemony.SystemInfo.dll
?????文件??????67072??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\obj\Debug\Lemony.SystemInfo.pdb
?????文件????????435??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\obj\Debug\SystemInfo.csproj.FileListAbsolute.txt
?????文件???????1559??2010-11-12?01:07??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\ProcessInfo.cs
?????文件???????1321??2007-03-29?09:04??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\Properties\AssemblyInfo.cs
?????文件??????17348??2010-11-12?01:08??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\SystemInfo.cs
?????文件???????2470??2013-09-18?17:28??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo\SystemInfo.csproj
?????文件???????1386??2013-09-18?17:28??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo.sln
????..A..H.?????25600??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\SystemInfo.suo
?????文件???????8830??2013-09-18?17:30??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\frmProcess.cs
?????文件??????26464??2007-03-29?15:58??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\frmProcess.designer.cs
?????文件???????6774??2007-03-29?15:58??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\frmProcess.resx
?????文件???????4181??2007-03-29?09:11??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\LineChart.cs
?????文件???????1599??2007-03-29?09:12??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\LineChart.Designer.cs
?????文件???????5814??2007-01-08?17:21??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\LineChart.resx
?????文件???????3844??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\obj\Debug\ResolveAssemblyReference.cache
?????文件????????743??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\obj\Debug\Test.csproj.FileListAbsolute.txt
?????文件????????914??2013-09-18?17:31??C#?仿Windows任務管理器矯正版\www.NewXing.com\Test\obj\Debug\Test.csproj.GenerateResource.Cache
............此處省略28個文件信息
- 上一篇:TINdelaunay三角網生成算法
- 下一篇:c# 驗證碼識別源代碼
評論
共有 條評論