32bit-64bit
Using intptr_t instead of void*?
Is it a good idea to use intptr_t as a general-purpose storage (to hold pointers and integer values) instead of void*? No. intptr_t is not guaranteed to exist. First, as you note, it was introduced in C99. Second, implementations are not required to have an integer type big enough to hold converted pointer values without … Read more
Windows command to tell whether a .dll file is 32 bit or 64 bit?
DUMPBIN is included with Visual C++ and can provide this information with the /HEADERS switch. Example output from a 32-bit image: FILE HEADER VALUES 14C machine (i386) 6 number of sections 306F7A22 time date stamp Sun Oct 01 22:35:30 1995 0 file pointer to symbol table 1D1 number of symbols E0 size of optional header … Read more
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
Running vbscript from batch file
You can use %~dp0 to get the path of the currently running batch file. Edited to change directory to the VBS location before running If you want the VBS to synchronously run in the same window, then @echo off pushd %~dp0 cscript necdaily.vbs If you want the VBS to synchronously run in a new window, … 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
Load 32-bit DLL library in 64-bit application
You can only load a 32bit DLL into a 64 bit process when you are loading the dll as a datafile. You can’t execute the code. (http://support.microsoft.com/kb/282423) Microsoft recommends that you use interprocess COM to use 32 bit code with a 64 bit application. Here’s an article explaining the process.