title: Detect Windows architecture (32 or 64 bit) with C++ - wProcessorArchitecture shows wrong results
body: <p>Im using this tiny piece of code to get to know if my Windows is 32 or 64 bit:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  static int is64bitOS()
  {
      SYSTEM_INFO si;
      GetSystemInfo(&amp;si);
  
      if((si.wProcessorArchitecture &amp; PROCESSOR_ARCHITECTURE_IA64)||(si.wProcessorArchitecture &amp; PROCESSOR_ARCHITECTURE_AMD64)==64)
      {
          return 1;
      }
      else
      {
          return 0;
      }
  }
  
  int main()
  {
      printf("%d\n", is64bitOS());
      return 0;
  }
  </code></pre>
  
  <p>I bought and installed 64 bit version of Windows 7 - however, the above code shows 0 meaning my os is 32 bit ... how to deal with it?</p>
  
  <p><strong>Ok, my other approaches, which basically do not work as well ...</strong> On my 64-bit Windows 7 I only see 32 bit ..</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  
  int getArchType1()
  {
      SYSTEM_INFO sysInfo;
      GetSystemInfo(&amp;sysInfo);
  
      switch(sysInfo.wProcessorArchitecture)
      {
      case 6:
          return 64;
      case 9:
          return 64;
      case 0:
          return 32;
      default:
          return -1;
      }
  }
  
  static char *getArchType2()
  {
      char *archType = malloc(sizeof(char) * (255));
      memset(archType, '\0', 255);
  
  #if defined _WIN64
      strcpy(archType, "64-bit");
  #else
      strcpy(archType, "32-bit");
  #endif // defined
  
      return archType;
  }
  
  int main()
  {
      char *arch = getArchType1();
      printf("%s\n", arch);
      free(arch);
      printf("%d\n", getArchType2());
      char c;
      scanf("%c", &amp;c);
      return 0;
  }
  </code></pre>