/// <Summary> /// obtain the installation information of the SOFTWARE in the registry. // The SOFTWARE will enter its own installation information in the registry. // HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ App Paths /// </summary> /// <param name = "softName"> Software name </param> /// <param name = "path"> return to the software installation path </param> /// <returns> whether the registry installation path is found </returns> public static bool TryGetSoftwarePath (string softName, out string path) {string strPathResult = string. empty; string strKeyName = "";//" (Default) "key, which contains the intalled path object objResult = null; Microsoft. win32.RegistryValueKind regValueKind; Microsoft. win32.RegistryKey regKey = null; Microsoft. win32.RegistryKey regSubKey = null; try {// Read the key regKey = Microsoft. win32.Registry. localMachine; regSubKey = regKey. openSubKey (@ "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ App Paths \" + softName. toString () + ". exe ", fa Lse); // Read the path objResult = regSubKey. getValue (strKeyName); regValueKind = regSubKey. getValueKind (strKeyName); // Set the path if (regValueKind = Microsoft. win32.RegistryValueKind. string) {strPathResult = objResult. toString () ;}} catch (System. security. securityException ex) {throw new System. security. securityException ("You have no right to read the registry! ", Ex);} catch (Exception ex) {throw new Exception (" Reading registry error! ", Ex);} finally {if (regKey! = Null) {regKey. Close (); regKey = null;} if (regSubKey! = Null) {regSubKey. Close (); regSubKey = null ;}} if (strPathResult! = String. Empty) {// Found path = strPathResult; return true;} else {// Not found path = null; return false ;}}