What’s an alternative to GWL_USERDATA for storing an object pointer?

SetWindowLongPtr was created to replace SetWindowLong in these instances. It’s LONG_PTR parameter allows you to store a pointer for 32-bit or 64-bit compilations. LONG_PTR SetWindowLongPtr( HWND hWnd, int nIndex, LONG_PTR dwNewLong ); Remember that the constants have changed too, so usage now looks like: SetWindowLongPtr(hWnd, GWLP_USERDATA, this); Also don’t forget that now to retrieve the … Read more

__int64 on a 32-Bit machine?

Same way 32-bit arithmetic worked on 16-bit systems. In this case, it uses 2 32-bit memory addresses to form a 64-bit number together. Addition/substraction is easy, you do it by parts, the only gotcha is taking the carry-over from the lower part to the higher part. For multiplication/division, it’s harder (ie more instructions). It’s obviously … Read more

Processor, OS : 32bit, 64 bit

Let’s try to answer this question by looking at people versus computers; hopefully this will shed some light on things for you: Things to Keep In Mind As amazing as they are, computers are very, very dumb. Memory People have memory (with the exception, arguably, of husbands and politicians.) People store information in their memory … Read more

As a programmer, what do I need to worry about when moving to 64-bit windows?

As far as I’m concerned, the single most important thing about porting C/C++ code to 64-bit Windows is to test your application with MEM_TOP_DOWN allocations enabled (AllocationPreference registry value) as described in 4-Gigabyte Tuning: To force allocations to allocate from higher addresses before lower addresses for testing purposes, specify MEM_TOP_DOWN when calling VirtualAlloc or set … Read more