How to programmatically detect 32-bit or 64-bit visio version is installed?
views:
129answers:
6Hi there.
You could search for the Visio EXE
file by using either:
Environment.SpecialFolder.ProgramFiles
Environment.SpecialFolder.ProgramFilesX86
If you find the Visio EXE
file in the X86 program files folder, then you know it's a 32-bit. The other folder is for 64-bit applications.
I'm not sure how fullproof this is though, since Visio could have been installed in a different folder other the Program Files
. In that case, you can still search for the EXE
file and then try to analyse the EXE
itself.
For that, check out these links:
- http://stackoverflow.com/questions/971689/win32-api-to-tell-whether-a-given-binary-exe-or-dll-is-x86-x64-or-ia64
- http://stackoverflow.com/questions/270531/how-to-determine-if-a-net-assembly-was-built-for-x86-or-x64-
Cheers. Jas.
You can check if it's installed in Program Files (x86)
(32 bits) or Program Files
(64 bits), but that's not rock solid.
The GetBinaryType API is probably a more solid solution.
One of the ways would be to look in the windows registry to see if visio exists under Office node(HKLM\Software\Wow6432Node\Microsoft\Office...) If exists, it indicates 32 bit version of Visio. If HKLM\Software\Microsoft\Office... lookup returns value, then it possibly indicates 64 bit version of visio installation. Hope this helps.
Can you elaborate a little more on when you need to determine VISIO is 64 or 32 bit?
If the process is running, you can use a P/Invoke method called IsWow64Process to determine if it is 64 bit or not.
You may also use IsWow64Process to determine if the OS is 32 or 64 bit. Once obtaining the bit space of the OS, then you can determine which version of your add-in to install.
From my understanding, Office 2010 and future releases, you can use VSTO to avoid checking if VISIO is 32-bit or 64-bit. You may want to consider that for future releases of your add-in.
Thanks
Also, I know this is unrelated, but please vote for this suggestion (if you have time) as it would revolutionize software development: https://connect.microsoft.com/VisualStudio/feedback/details/526951/screen-object-physicalwidthincentimeters-physicalheightincentimeters-displaymode
Try the Application.IsVisio32 property
I think it's left over from when there was a distinction between the 16 and 32 bit versions of Visio, but the IsVisio32 is still there (at least in Visio 2003 32-bit, and Visio2010 32-bit.
There is no IsVisio64 property, but see what IsVisio32 comes out with on a 64 bit install, if you can.