熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#中判斷某軟件是否已安裝

2022-06-13   來源: .NET編程 

  private void button_Click(object sender EventArgs e)

  {

  if (checkAdobeReader() == true)

  {

  MessageBoxShow(有安裝 Adobe Reader );

  }

  else

  {

  MessageBoxShow(沒有安裝 Adobe Reader );

  }

  }

  /// <summary>

  /// 確認是否有安裝 Adobe Reader

  /// </summary>

  /// <returns>true: 有安裝 false:沒有安裝</returns>

  private bool checkAdobeReader()

  {

  MicrosoftWinRegistryKey uninstallNode = MicrosoftWinRegistryLocalMachineOpenSubKey(@SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall);

  foreach (string subKeyName in uninstallNodeGetSubKeyNames())

  {

  MicrosoftWinRegistryKey subKey = uninstallNodeOpenSubKey(subKeyName);

  object displayName = subKeyGetValue(DisplayName);

  if (displayName != null)

  {

  if (displayNameToString()Contains(Adobe Reader))

  {

  return true;

  // MessageBoxShow(displayNameToString());

  }

  }

  }

  return false;

  }


From:http://tw.wingwit.com/Article/program/net/201311/13109.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.