Over a million developers have joined DZone.

Verifying Visual C++ Redistributable Files in Custom .NET Applications

DZone's Guide to

Verifying Visual C++ Redistributable Files in Custom .NET Applications

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

This article was written by the Imaginovation team.  They are a Raleigh web design and software development company who uses .NET, PHP, HTML5, JavaScript, and jQuery technologies.

As you may already know the MS VC++ Redistributable run time files allow you to execute programs which were developed with specific versions of Visual Studio.  The need might arise to check a client system for these files in the scenario where you are deploying you’re application and want to deploy the VCR’s iff the user’s system does not have these installed, saving time and overhead.

First let’s get past the very difficult and confusing naming convention:
VCR7(which we will not discuss how to detect in this article) corresponds to Visual Studio 2003

VCR8 corresponds to Visual Studio 2005

VCR9 corresponds to Visual Studio 2008

VCR10 corresponds to Visual Studio 2010

Next we will detect the presence of these VCR’s and add it to a list of strings using the following code snippet:
The enumerated type is first defined:
public enum INSTALLSTATE


           INSTALLSTATE_NOTUSED = -7,  // component disabled

           INSTALLSTATE_BADCONFIG = -6,  // configuration data corrupt

           INSTALLSTATE_INCOMPLETE = -5,  // installation suspended or in progress

           INSTALLSTATE_SOURCEABSENT = -4,  // run from source, source is unavailable

           INSTALLSTATE_MOREDATA = -3,  // return buffer overflow

           INSTALLSTATE_INVALIDARG = -2,  // invalid function argument

           INSTALLSTATE_UNKNOWN = -1,  // unrecognized product or feature

           INSTALLSTATE_BROKEN = 0,  // broken

           INSTALLSTATE_ADVERTISED = 1,  // advertised feature

           INSTALLSTATE_REMOVED = 1,  // component being removed(action state, not settable)

           INSTALLSTATE_ABSENT = 2,  // uninstalled (or action state absent but clients remain)

           INSTALLSTATE_LOCAL = 3,  // installed on local drive

           INSTALLSTATE_SOURCE = 4,  // run from source, CD or net

           INSTALLSTATE_DEFAULT = 5,  // use default, local or source

/*Use this function to determine which bit type of the VCR is installed.  The below logic is basically saying if you can open the key then it exists (you can pass in only certain states depending on your needs.  The most commonly “good states” I use are Local and Default, you might need to pass in all states for debugging purposes.
        private void CheckVCKey(string _vcKey, string _state)


            string value64 = string.Empty;

            string value32 = string.Empty;


            if (Environment.Is64BitOperatingSystem == true)



                RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);

                localKey = localKey.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + _vcKey);


                if (localKey != null)


                    value64 = localKey.GetValue("DisplayName").ToString() + " at Registry Key " + _vcKey + " with a state of " + _state;





            RegistryKey localKey32 = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);


            localKey32 = localKey32.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" + _vcKey);

            if (localKey32 != null)


                value32 = localKey32.GetValue("DisplayName").ToString() + " at Registry Key " + _vcKey + " with a state of " + _state; ;



public bool IsVCRedistInstalled()

       string[,] strCodes = new string[,]  (this is the most important (and annoying) part of this document, and this string list will be defined below the code snippet)


for (int i = 0;i < strCodes.Length; i++){

                //you can modify this as needed with any of the enumerated types


                     state == INSTALLSTATE.INSTALLSTATE_DEFAULT)


                   CheckVCKey(strCodes[i], state.ToString());



Now we will list the codes (please be aware this is an ever changing list and I will try to keep it updated as much as I can)  :

string[,] strCodes = new string[,]



                //vcredist_x86 - ProductCode

                {"{710f4c1c-cc18-4c49-8cbf-51240c89a1a2}"},   //8.0.61001  - distributed in 152





                //vcredist_x64 - ProductCode






                //vcredist_IA64 - ProductCode







                //vcredist_x86 - ProductCode















                //vcredist_x64 - ProductCode















                //vcredist_IA64 - ProductCode














                //vc10_x86 - ProductCode




                 //vc10_x64 - ProductCode






//vc10_x86 - ProductCode







I hope this article helps those in need of detecting VCR’s and you had as much fun reading it as I did writing it!

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.


Published at DZone with permission of Michael Georgiou. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}