0

I am using Visual Studio 2008 to write applications. When deploying the app, some of the systems are 32bit, while the others are 64bit. Therefore, I plan to deliver both 32bit/64bit version in the installer, then launch the corresponding version based on the bitness of the OS. How to implement the latter, i.e., get the bitness of the OS and launch the corresponding version?

Let me clarify the situation. I already developed both 32bit and 64bit EXE application with C++. Then I want to detect the bitness of the Windows in C++(I don't know .NET) and launch the corresponding version of application.

Thanks

alancc
  • 487
  • 2
  • 24
  • 68
  • Probably write a 32-bit installer (so it can run anywhere), and have it extract + try to launch a 64-bit test executable. That will either return an error (unsupported executable), or the executable will run successfully and return a non-error exit status. Like `int main(){return 0;}`. – Peter Cordes Jun 05 '18 at 03:28
  • Or wait, do you want to choose once at install time, or always install both and choose at runtime every time? – Peter Cordes Jun 05 '18 at 04:28
  • 2
    from 32bit installer call [`IsWow64Process`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684139(v=vs.85).aspx) or [`NtQueryInformationProcess`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684280(v=vs.85).aspx) with `ProcessWow64Information` and if detect wow64 process - launch 64bit installer and exit – RbMm Jun 05 '18 at 06:39

2 Answers2

1

I would recommend looking for a more powerful MSI packaging tool. Most professional tools offer you a built-in bootstrapper that provides this functionality with one click.

The VS setup project is useful for basic application packaging, but never intended to offer you full power.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
0

It depends on what you mean by "launch the corresponding version". This implies that you already have code written that needs to choose, in which case this isn't an installer question at all - you just need to find the bitness of the OS and then install the appropriate MSI file (or VS-generated setup.exe). If it's a C# launcher you'd perhaps use Environment.Is64BitOperatingSystem.

Your question doesn't say if you are delivering code (assemblies, COM Dlls etc) that will be used by client programs. I mention this because your 32-bit setup will install and run on 64-bit OS versions in the 32-bit subsystem. The 64-bit version will presumably contain only native 64-bit code.

Note that your 64-bit setup won't install on a 32-bit OS anyway.

PhilDW
  • 20,260
  • 1
  • 18
  • 28