System.UIntPtr

本文详细介绍了.NET Framework中UIntPtr结构的定义与实现细节,包括构造方法、显式类型转换操作符、成员方法等,并提供了该结构的源码解析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using System.Globalization;
using System.Runtime.InteropServices;
namespace System
{
[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi),Serializable,CLSCompliant(false),ComVisible(true)]
public struct UIntPtr:System.Runtime.Serialization.ISerializable
{  
 private void* m_value;
 public static readonly System.UIntPtr Zero;
 public UIntPtr(uint @value)
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldarg.1
   //IL_0002:  conv.u
   //IL_0003:  stfld      void* System.UIntPtr::m_value
   //IL_0008:  ret
          return this.m_value=(void*)@value;
 }
 public UIntPtr(ulong @value)
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldarg.1
   //IL_0002:  conv.ovf.u4.un
   //IL_0003:  conv.u
   //IL_0004:  stfld      void* System.UIntPtr::m_value
   //IL_0009:  ret
          return this.m_value = (void*)checked((uint)@value);
 }
 public UIntPtr(void* @value)
 {
   //System.CLSCompliantAttribute(false)
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldarg.1
   //IL_0002:  stfld      void* System.UIntPtr::m_value
   //IL_0007:  ret
          return this.m_value = @value;
 }
 private UIntPtr( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
 {
   //.maxstack  2
   //.locals init (uint64 V_0)
   //IL_0000:  ldarg.1
   //IL_0001:  ldstr      "value"
   //IL_0006:  callvirt   instance uint64 System.Runtime.Serialization.SerializationInfo::GetUInt64(string)
   //IL_000b:  stloc.0
   //IL_000c:  call       int32 System.UIntPtr::get_Size()
   //IL_0011:  ldc.i4.4
   //IL_0012:  bne.un.s   IL_0029
   //IL_0014:  ldloc.0
   //IL_0015:  ldc.i4.m1
   //IL_0016:  conv.u8
   //IL_0017:  ble.un.s   IL_0029
   //IL_0019:  ldstr      "Serialization_InvalidPtrValue"
   //IL_001e:  call       string System.Environment::GetResourceString(string)
   //IL_0023:  newobj     instance void System.ArgumentException::.ctor(string)
   //IL_0028:  throw
   //IL_0029:  ldarg.0
   //IL_002a:  ldloc.0
   //IL_002b:  conv.u
   //IL_002c:  stfld      void* System.UIntPtr::m_value
   //IL_0031:  ret
          ulong V_0;
          V_0 = info.GetUInt16("value");
          if(System.UIntPtr.Size==4)
          {
              if (V_0 <= 0xFFFFFFFFuL)
              {
                  this.m_value = (void*)V_0;
              }
              else
              {
                  throw new System.ArgumentException(System.Environment.GetResourceString("Serialization_InvalidPtrValue"));
              }
          }
          else
          {
              this.m_value = (void*)V_0;
          }
 }
 new virtual sealed void System.Runtime.Serialization.ISerializable.GetObjectData( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
 {
   //.override System.Runtime.Serialization.ISerializable::GetObjectData
   //.maxstack  8
   //IL_0000:  ldarg.1
   //IL_0001:  brtrue.s   IL_000e
   //IL_0003:  ldstr      "info"
   //IL_0008:  newobj     instance void System.ArgumentNullException::.ctor(string)
   //IL_000d:  throw
   //IL_000e:  ldarg.1
   //IL_000f:  ldstr      "value"
   //IL_0014:  ldarg.0
   //IL_0015:  ldfld      void* System.UIntPtr::m_value
   //IL_001a:  conv.u8
   //IL_001b:  callvirt   instance void System.Runtime.Serialization.SerializationInfo::AddValue(string,
                                                                                               //uint64)
   //IL_0020:  ret
          if (info == null)
          {
              throw new System.ArgumentNullException("info"); 
          }
          else
          {
              info.AddValue("value",(ulong)this.m_value);
          }
 }
 public override bool Equals(object obj)
 {
   //.maxstack  2
   //.locals init (native uint V_0)
   //IL_0000:  ldarg.1
   //IL_0001:  isinst     System.UIntPtr
   //IL_0006:  brfalse.s  IL_001f
   //IL_0008:  ldarg.0
   //IL_0009:  ldfld      void* System.UIntPtr::m_value
   //IL_000e:  ldarg.1
   //IL_000f:  unbox.any  System.UIntPtr
   //IL_0014:  stloc.0
   //IL_0015:  ldloca.s   V_0
   //IL_0017:  ldfld      void* System.UIntPtr::m_value
   //IL_001c:  ceq
   //IL_001e:  ret
   //IL_001f:  ldc.i4.0
   //IL_0020:  ret
          System.UIntPtr V_0;
          if (obj is System.UIntPtr)
          {              
              V_0=(System.UIntPtr)obj;
              return this.m_value == V_0.m_value;
          }
          else
          {
              return false;
          }
 }
 public override int GetHashCode()
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldfld      void* System.UIntPtr::m_value
   //IL_0006:  conv.u8
   //IL_0007:  conv.i4
   //IL_0008:  ldc.i4     0x7fffffff
   //IL_000d:  and
   //IL_000e:  ret
          return (int)(ulong)this.m_value & 0x7ffffff;
          
 }
 public uint ToUInt32()
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldfld      void* System.UIntPtr::m_value
   //IL_0006:  conv.u4
   //IL_0007:  ret
          return (uint)this.m_value;
 }
 public ulong ToUInt64()
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldfld      void* System.UIntPtr::m_value
   //IL_0006:  conv.u8
   //IL_0007:  ret
          return (ulong)this.m_value;
 }
 public virtual string ToString()
 {
   //.maxstack  2
   //.locals init (uint32 V_0)
   //IL_0000:  ldarg.0
   //IL_0001:  ldfld      void* System.UIntPtr::m_value
   //IL_0006:  conv.u4
   //IL_0007:  stloc.0
   //IL_0008:  ldloca.s   V_0
   //IL_000a:  call       class System.Globalization.CultureInfo System.Globalization.CultureInfo::get_InvariantCulture()
   //IL_000f:  call       instance string System.UInt32::ToString(class System.IFormatProvider)
   //IL_0014:  ret
          uint V_0 = (uint)this.m_value;
          return V_0.ToString(CultureInfo.InvariantCulture);
 }
 public static System.UIntPtr op_Explicit(uint @value)
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  newobj     instance void System.UIntPtr::.ctor(uint32)
   //IL_0006:  ret
          return new UIntPtr(@value);
 }
 public static System.UIntPtr op_Explicit(ulong @value)
 {
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  newobj     instance void System.UIntPtr::.ctor(uint64)
   //IL_0006:  ret
          return new UIntPtr(@value);
 }
 public static uint op_Explicit(System.UIntPtr @value)
 {
   //.maxstack  8
   //IL_0000:  ldarga.s   'value'
   //IL_0002:  ldfld      void* System.UIntPtr::m_value
   //IL_0007:  conv.u4
   //IL_0008:  ret
          return (uint)@value.m_value;
 }
 public static ulong op_Explicit(System.UIntPtr @value)
 {
   //.maxstack  8
   //IL_0000:  ldarga.s   'value'
   //IL_0002:  ldfld      void* System.UIntPtr::m_value
   //IL_0007:  conv.u8
   //IL_0008:  ret
          return (ulong)@value.m_value;
 }
        [CLSCompliant(false)]
 public static System.UIntPtr op_Explicit(void* @value)
 {    
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  newobj     instance void System.UIntPtr::.ctor(void*)
   //IL_0006:  ret
          return new UIntPtr(@value);
 }
        [CLSCompliant(false)]
 public static void* op_Explicit(System.UIntPtr @value)
 {   
   //.maxstack  8
   //IL_0000:  ldarga.s   'value'
   //IL_0002:  call       instance void* System.UIntPtr::ToPointer()
   //IL_0007:  ret
          return @value.ToPointer();
 }
 public static bool op_Equality(System.UIntPtr value1, System.UIntPtr value2)
 {
   //.maxstack  8
   //IL_0000:  ldarga.s   value1
   //IL_0002:  ldfld      void* System.UIntPtr::m_value
   //IL_0007:  ldarga.s   value2
   //IL_0009:  ldfld      void* System.UIntPtr::m_value
   //IL_000e:  ceq
   //IL_0010:  ret
          return value1.m_value == value2.m_value;
 }
 public static bool op_Inequality(System.UIntPtr value1, System.UIntPtr value2)
 {
   //.maxstack  8
   //IL_0000:  ldarga.s   value1
   //IL_0002:  ldfld      void* System.UIntPtr::m_value
   //IL_0007:  ldarga.s   value2
   //IL_0009:  ldfld      void* System.UIntPtr::m_value
   //IL_000e:  ceq
   //IL_0010:  ldc.i4.0
   //IL_0011:  ceq
   //IL_0013:  ret
          return (value1.m_value == value2.m_value)==false;
 }
      public static int Size
      {
          get
          {
              ;
          }
          //.get int32 System.UIntPtr::get_Size()
      }
 public static int get_Size()
 {
   //.maxstack  8
   //IL_0000:  ldc.i4.4
   //IL_0001:  ret
          return 4;
 }
 public void* ToPointer()
 {
   //System.CLSCompliantAttribute(false)
   //.maxstack  8
   //IL_0000:  ldarg.0
   //IL_0001:  ldfld      void* System.UIntPtr::m_value
   //IL_0006:  ret
          return this.m_value;
 }
 
}
}

转载于:https://www.cnblogs.com/MSIL/articles/1811416.html

System.Data.SyntaxErrorException HResult=0x80131920 Message=Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier. Source=System.Data.Common StackTrace: 在 System.Data.ExpressionParser.ParseAggregateArgument(FunctionId aggregate) 在 System.Data.ExpressionParser.Parse() 在 System.Data.DataExpression..ctor(DataTable table, String expression, Type type) 在 System.Data.DataTable.Compute(String expression, String filter) 在 WinFormsApp1.Form1.button6_Click(Object sender, EventArgs e) 在 D:\Work_File\C#\TEST\可视化图表\WinFormsApp1\Form1.cs 中: 第 207 行 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs 中: 第 248 行 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Button.cs 中: 第 275 行 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs 中: 第 12350 行 在 System.Windows.Forms.Control.WndProc(Message& m) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Control.cs 中: 第 13125 行 在 System.Windows.Forms.ButtonBase.WndProc(Message& m) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs 中: 第 1446 行 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Control.ControlNativeWindow.cs 中: 第 112 行 在 System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/NativeWindow.cs 中: 第 372 行 在 Windows.Win32.PInvoke.DispatchMessage(MSG* lpMsg) 在 System.Windows.Forms.Application.ComponentManager.Microsoft.Office.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Application.ComponentManager.cs 中: 第 290 行 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs 中: 第 1063 行 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context) 在 /_/src/System.Windows.Forms/src/System/Windows/Forms/Application.ThreadContext.cs 中: 第 929 行 在 WinFormsApp1.Program.Main() 在 D:\Work_File\C#\TEST\可视化图表\WinFormsApp1\Program.cs 中: 第 24 行
07-05
$code = @' using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; using System.Collections.Concurrent; using System.Windows.Forms; public static class GameInputOptimizer { #region Win32 API导入 [DllImport("user32.dll")] private static extern short GetAsyncKeyState(int vKey); [DllImport("user32.dll")] private static extern bool GetCursorPos(out POINT lpPoint); [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] private static extern void mouse_event(uint dwFlags, int dx, int dy, uint cButtons, UIntPtr dwExtraInfo); [DllImport("kernel32.dll")] private static extern IntPtr GetCurrentProcess(); [DllImport("kernel32.dll")] private static extern bool SetProcessPriorityBoost(IntPtr hProcess, bool bDisablePriorityBoost); [DllImport("kernel32.dll")] private static extern bool SetPriorityClass(IntPtr hProcess, uint dwPriorityClass); [DllImport("kernel32.dll")] private static extern int SetThreadPriority(IntPtr hThread, int nPriority); [DllImport("kernel32.dll")] private static extern IntPtr GetCurrentThread(); [DllImport("ntdll.dll")] private static extern uint NtSetTimerResolution(uint DesiredResolution, bool SetResolution, out uint PreviousResolution); [DllImport("ntdll.dll")] private static extern uint NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint CurrentResolution); [DllImport("kernel32.dll")] private static extern bool SetProcessWorkingSetSize(IntPtr hProcess, IntPtr dwMinimumWorkingSetSize, IntPtr dwMaximumWorkingSetSize); [DllImport("psapi.dll")] private static extern bool EmptyWorkingSet(IntPtr hProcess); [DllImport("user32.dll", SetLastError = true)] private static extern uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize); [DllImport("winmm.dll")] private static extern uint timeBeginPeriod(uint per
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值