0

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.

Raheel Khan
  • 14,205
  • 13
  • 80
  • 168

1 Answers1

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

Tigran
  • 61,654
  • 8
  • 86
  • 123
  • Thanks. I'm glad you said **"most cases"**. Any clues on how to determine whether an instance is 32 or 64 bit? – Raheel Khan Jun 11 '13 at 08:52
  • @RaheelKhan: not sure, but according to the help, it related to the OS platform, son in case you identfy OS is 64bit, use ToInt64(), but I repeat, I'm not sure on this. – Tigran Jun 11 '13 at 09:09