问题
Three related questions here:
- The
IntPtr
structure apparently does not implement<
and>
operators. Is there a way to perform this comparison without converting the structure to an int or long? - Why are the
<
and>
operators not implemented on this structure? - I am enumerating windows from a 32 bit process. Windows from 64 bit processes also seem to be included, which is fine. How can I tell whether to use ToInt32 or ToInt64 on the IntPtr structure?
Context: Windows 7 (64 bit), VS 2010, WinForms (32 bit).
The target windows I want to extract include 64 bit apps such as the Windows Sidebar containing gadgets. If I have taken any wrong assumptions, please let me know.
回答1:
Why are the < and > operators not implemented on this structure?
Because there is no point (in most cases) of comparing if address of a pointer is less or bigger of some other number or other address. By the way IntPtr class provides equality function too.
IntPtr.Equals
来源:https://stackoverflow.com/questions/17039736/using-intptr-with-icomparert