The correct way to compare distances between pointers to different objects is to convert them to integers.
I read this once on Raymond Chen's blog, but I can't find the article now.
Raymond Chen's blog has a lot of C++ and Win32 knowledge. Although you won’t find the answers to all your questions on his blog, if you can find the answer there, it will definitely be an easy-to-understand answer.