How to detect on C++ is windows 32 or 64 bit? -
how detect on c++ windows 32 or 64 bit? see lot of examples in .net need c++. iswow64process() dosen't works me, becouse "if process running under 32-bit windows, value set false. if process 64-bit application running under 64-bit windows, value set false"
if have 32 bit proc under 32 bit os have false if have 64 bit proc under 64 bit os have false
but dont care process bit need os bit
the win32 api function detect information underlying system getnativesysteminfo
. call function , read wprocessorarchitecture
member of system_info
struct function populates.
although possible use iswow64process
detect this. if call iswow64process
, true
returned, know running on 64 bit system. otherwise, false
returned. , need test size of pointer, instance. 32 bit pointer indicates 32 bit system, , 64 bit pointer indicates 64 bit system. in fact, can information conditional supplied compiler, depending on compiler use, since size of pointer known @ compile time.
raymond chen described approach in blog article. helpfully included code reproduce here:
bool is64bitwindows() { #if defined(_win64) return true; // 64-bit programs run on win64 #elif defined(_win32) // 32-bit programs run on both 32-bit , 64-bit windows // must sniff bool f64 = false; return iswow64process(getcurrentprocess(), &f64) && f64; #else return false; // win64 not support win16 #endif }
Comments
Post a Comment