In the process of achieving 64bit compatibility, developers usually opt for higher but stable version of compiler. On windows it is Visual C++ compiler version higher than VC++ 98(i.e. VC 6.0). That’s where the technical challenge of finding VC++ runtime installation comes to picture. Why? The answer to this is that, when developer opt for a newer compiler for example Visual Studio 2005, it introduces its own technical issue in deployment. Either VC++ runtime libraries should be shipped with the product or they can be installed similar to any other package installation to fulfill your product dependency.

Now there are situations where the custom installer should determine whether a particular version of VC++ runtime distribution package is installed on deployment system or not.

The code below will help you to determine VC++ runtime distribution as well as architecture check.

#include <msi.h>
#include <windows.h>
#include <stdio.h>

// forward declaration
BOOL Is64BitWindows();


int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
	INSTALLSTATE install_state;

		::MessageBox(NULL, "64bit Operating System" ,"Success",MB_OK | MB_ICONINFORMATION);
		install_state = MsiQueryProductState("{071c9b48-7c32-4621-a0ac-3f809523288f}");  //for x64 runtime
		::MessageBox(NULL, "32bit Operating System" ,"Success",MB_OK | MB_ICONINFORMATION);
		install_state = MsiQueryProductState("{7299052b-02a4-4627-81f2-1818da5d550d}"); // for x86 runtime

	//for IA64
	//install_state = MsiQueryProductState("{0f8fb34e-675e-42ed-850b-29d98c2ece08}"); 

	if ( install_state == INSTALLSTATE_DEFAULT )
		::MessageBox(NULL, "VC++ 2005 SP1 Runtime already installed" ,"Success",MB_OK | MB_ICONINFORMATION);
		::MessageBox(NULL, "Please install VC++ 2005 SP1 Runtime package to continue...","Error",MB_OK | MB_ICONERROR);
	return 0;

// Detect whether operating system is 32bit or 64bit 
BOOL Is64BitWindows()
	#if defined(_WIN64)
	 return TRUE;  // 64-bit programs run only on Win64
	#elif defined(_WIN32)
	 // 32-bit programs run on both 32-bit and 64-bit Windows
	 // so must sniff
	 BOOL bIsWow64 = FALSE;

	 fnIsWow64Process= (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

	 if (NULL != fnIsWow64Process)
		if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
			::MessageBox(NULL, "Please install VC++ 2005 SP1 Runtime package to continue...","Error",MB_OK | MB_ICONERROR);

	 return bIsWow64;
	 return FALSE; // Win64 does not support Win16

Some tips and tricks on how we achieved this:

The string that you find in above code as a parameter to MsiQueryProductState(..) function is specific to vc++ runtime sp2 version. You will get similar strings for other versions too.

MsiQueryProductState(..) function returns install state of the product . Using which one can determine the state of package installation.

Is64BitWindows(..) function will determine the architecture of the machine where the process is running. It even takes care of process running under WOW64bit emulation mode.

If you need more information feel free to approach me. I would help you in resolving similar issues.

0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Categories: Uncategorized

Disclaimer: As with everything else at NetIQ Cool Solutions, this content is definitely not supported by NetIQ, so Customer Support will not be able to help you if it has any adverse effect on your environment.  It just worked for at least one person, and perhaps it will be useful for you too.  Be sure to test in a non-production environment.

Leave a Reply

No Comments
May 15, 2008
3:00 pm
Active Directory Authentication Automation Cloud Computing Cloud Security Configuration Customizing Data Breach DirXML Drivers End User Management Identity Manager Importing-Exporting / ICE/ LDIF Intelligent Workload Management Knowledge Depot LDAP Monitoring Open Enterprise Server Passwords Reporting Secure Access Sentinel Supported Troubleshooting Workflow