Luis, I'm not trying to pick an argument, this is not a competition.
I'm not engaging myself in some rampant speculation about your motivations, I'm only interested in the informations presented in the thread, let's see them again one last time.
IdeasVacuum wrote:A 64bit app does not need to test, since it will only run on 64bit.
Yes. It's really as you say. I confirm it wholeheartedly. But a program compiled for both 32 and 64 bit may require that test, unless you want two different sources for the same program (a 64 bit version who "knows" and a 32 bit version who need to ask).
You can then call one of the two functions proposed here by SFSxOI and myself, under any condition, and get the correct reply.
Hence you can store one of those away as a library function, forget about its internals, and simply use it from now on.
OR you can skip half of that test (sizeof()), and have a correct reply only if you compiled the exe to 32 bit.
OR you can check if your exe is 64 bit outside from that procedure, don't call it, and call it if the exe is 32 bit.
OR you can compile your program to 64 bit only and avoid a check at all because it will run only if the OS is 64 bit.
Take your pick.
Now about the "why" I'm replying to you ? Because I want to win a competition ? Because I like to argue since I don't have many interests in life and I'm boring myself to death every passing day ? Nope.
I replied to you because you said about the use of SizeOf(): "This is deemed unreliable at runtime (via exe) if your app is 32bit running on a 64bit OS".
I found that wrong in the context of how sizeof() was used here, and I explained sizeof() is reliable by definition, the only way to THINK it is unreliable is to use it wrongly (in the way you mentioned), probably that was what the google links were talking about but as you know I wasn't able to check them.
Then I replied to you because you said using sizeof() was unneeded (I disagreed and explained why can be useful in this context).
Then I replied to you when you asked why we need it if the API call was enough (I explained why it may not be enough).
And in the end I conceded your test is enough if you plan to compile your program only as a 32 bit exe and you cannot afford a SizeOf().
That's it. Is there something wrong with all that ? Because I don't see it.
You prefer your way ? It's fine. But I can reply if I believe your is not the best way to approach the problem (especially because later other people can read this and make wrong assumptions) or if you ask me a question. In fact I did.