我如何检查是否安装了应用程序

编程入门 行业动态 更新时间:2024-10-27 22:22:26
本文介绍了我如何检查是否安装了应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

hi i有这个代码来检查是否已安装,并且它工作得非常好

string 键; bool data = false ; 尝试 { key = Registry.LocalMachine.OpenSubKey( SOFTWARE)。OpenSubKey( Microsoft)。OpenSubKey( Windows)。OpenSubKey( CurrentVersion)。OpenSubKey( 卸载)。GetValue( 50727)。ToString( ); } catch (例外) {} data =(key == 50727-50727); label1.text = 已安装;

i试图使用相同的代码更改anothor应用程序的位置,但它会结束 32bit系统

string key1; bool data1 = false ; 尝试 { key1 = Registry.LocalMachine.OpenSubKey( SOFTWARE)。OpenSubKey( Wow6432Node)。OpenSubKey( Microsoft)。OpenSubKey( Windows)。OpenSubKey( CurrentVersion)。OpenSubKey( 卸载 ).OpenSubKey( Mozilla Firefox 38.0.1(x86 zh-CN))。GetValue( DisplayName)。ToString(); } catch (例外) {} data1 =(key1 = = Mozilla Firefox 38.0.1(x86 zh-CN)); label10.Text = Mozilla Firefox - + data1.ToString( );

64bit系统

string key1; bool data1 = false ; 尝试 { key1 = Registry.LocalMachine.OpenSubKey( SOFTWARE)。OpenSubKey( Microsoft)。OpenSubKey( Windows)。OpenSubKey( CurrentVersion)。OpenSubKey( 卸载)。OpenSubKey( Mozilla Firefox 38.0.1( x86 zh-CN))。GetValue( DisplayName)。ToString() ; } catch (例外) {} data1 =(key1 = = Mozilla Firefox 38.0.1(x86 zh-CN)); label10.Text = Mozilla Firefox - + data1.ToString( );

任何想法?

解决方案

阅读: stackoverflow/questions/908850/get-installed-applications-in- a-system [ ^ ]

感谢所有人,这解决了我的问题 检查应用程序是否安装在注册表中 public static bool checkInstalled( string c_name) { string displayName; string registryKey = @ SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall; RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey); if (key!= null ) { foreach (RegistryKey子键 in key.GetSubKeyNames()。选择(keyName = > key.OpenSubKey(keyName))) { displayName = subkey.GetValue( DisplayName) as string ; if (displayName!= null && displayName.Contains(c_name)) { return true ; } } key.Close(); } registryKey = @ SOFTWARE \Wow6432Node\Microsoft \ Windows\CurrentVersion\Uninstall; key = Registry.LocalMachine.OpenSubKey(registryKey); if (key!= null ) { foreach (RegistryKey子键 in key.GetSubKeyNames()。选择(keyName = > key.OpenSubKey(keyName))) { displayName = subkey.GetValue( DisplayName) as string ; if (displayName!= null && displayName.Contains(c_name)) { return true ; } } key.Close(); } 返回 false ; }

我只是简单地使用

如果(checkInstalled ( 应用程序名称))

hi i have this code to check if installed , and it work very good

string key; bool data = false; try { key = Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall").GetValue("50727").ToString(); } catch (Exception) { } data = (key == "50727-50727"); label1.text = "installed";

i tried to used same code with change the location for anothor apps but it faild 32bit system

string key1; bool data1 = false; try { key1 = Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Wow6432Node").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall").OpenSubKey("Mozilla Firefox 38.0.1 (x86 en-GB)").GetValue("DisplayName").ToString(); } catch (Exception) { } data1 = (key1 == "Mozilla Firefox 38.0.1 (x86 en-GB)"); label10.Text = "Mozilla Firefox - " + data1.ToString();

64bit system

string key1; bool data1 = false; try { key1 = Registry.LocalMachine.OpenSubKey("SOFTWARE").OpenSubKey("Microsoft").OpenSubKey("Windows").OpenSubKey("CurrentVersion").OpenSubKey("Uninstall").OpenSubKey("Mozilla Firefox 38.0.1 (x86 en-GB)").GetValue("DisplayName").ToString(); } catch (Exception) { } data1 = (key1 == "Mozilla Firefox 38.0.1 (x86 en-GB)"); label10.Text = "Mozilla Firefox - " + data1.ToString();

any idea ?

解决方案

Read this : stackoverflow/questions/908850/get-installed-applications-in-a-system[^]

thanks for all , this solved my Q Check if application is installed in registry

public static bool checkInstalled (string c_name) { string displayName; string registryKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; RegistryKey key = Registry.LocalMachine.OpenSubKey(registryKey); if (key != null) { foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) { displayName = subkey.GetValue("DisplayName") as string; if (displayName != null && displayName.Contains(c_name)) { return true; } } key.Close(); } registryKey = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; key = Registry.LocalMachine.OpenSubKey(registryKey); if (key != null) { foreach (RegistryKey subkey in key.GetSubKeyNames().Select(keyName => key.OpenSubKey(keyName))) { displayName = subkey.GetValue("DisplayName") as string; if (displayName != null && displayName.Contains(c_name)) { return true; } } key.Close(); } return false; }

And I simply just call it using

if(checkInstalled("Application Name"))

更多推荐

我如何检查是否安装了应用程序

本文发布于:2023-07-17 06:35:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1130451.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   安装了

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!