2011-08-09 4 views
3

私はプログラミング初心者です。私は仮想会議のサイトを与えられました。今私はサイトを変更する必要があります。特定のソフトウェアがWindowsにインストールされているかどうかを検出する方法はありますか?

ユーザは会議サイトにログインしている間に、システムに特定のソフトウェアがインストールされているかどうかを検出する必要があります(そのソフトウェアはビデオコールの作成に使用されます。

システムにインストールされているソフトウェアの存在を検出する最も良い方法はどれですか? (確かに私はどの言語が目的に最も適しているのかも知らない)

答えて

2
public static bool IsApplictionInstalled(string p_name) 
{ 
    string keyName; 

    // search in: CurrentUser 
    keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; 
    if (ExistsInSubKey(Registry.CurrentUser, keyName, "DisplayName", p_name) == true) 
    { 
     return true; 
    } 

    // search in: LocalMachine_32 
    keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"; 
    if (ExistsInSubKey(Registry.LocalMachine, keyName, "DisplayName", p_name) == true) 
    { 
     return true; 
    } 

    // search in: LocalMachine_64 
    keyName = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"; 
    if (ExistsInSubKey(Registry.LocalMachine, keyName, "DisplayName", p_name) == true) 
    { 
     return true; 
    } 

    return false; 
} 

private static bool ExistsInSubKey(RegistryKey p_root, string p_subKeyName, string p_attributeName, string p_name) 
{ 
    RegistryKey subkey; 
    string displayName; 

    using (RegistryKey key = p_root.OpenSubKey(p_subKeyName)) 
    { 
     if (key != null) 
     { 
      foreach (string kn in key.GetSubKeyNames()) 
      { 
       using (subkey = key.OpenSubKey(kn)) 
       { 
        displayName = subkey.GetValue(p_attributeName) as string; 
        if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) 
        { 
         return true; 
        } 
       } 
      } 
     } 
    } 
    return false; 
} 
+0

-1:幸いにも、それはウェブアプリからレジストリにアクセスすることは不可能です。彼は、サーバーマシン上のActiveXマシンの存在をチェックするのではなく、クライアントマシン上でチェックします。 –

+0

@Naresh thanduありがとう!! urコードは本当にたくさん助けました – kairav

4

あなたはシステムにアクセスできないので、これを本当に検出することはできません。 Webアプリケーションは、そのActiveXのインスタンスを作成し、それが失敗した場合にユーザーにメッセージを表示しようとします。

0

ありがとうございました。しかし、私はこのプログラムをC#で使いました。このクラスライブラリを作成し、ウェブページにdllをロードして、IsApplicationInstalledメソッドを使用しました。

public static bool IsApplicationInstalled(string p_name) 
{ 
string displayName; 
RegistryKey key; 

// search in: CurrentUser 
key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); 
foreach (String keyName in key.GetSubKeyNames()) 
{ 
    RegistryKey subkey = key.OpenSubKey(keyName); 
    displayName = subkey.GetValue("DisplayName") as string; 
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) 
    { 
     return true; 
    } 
} 

// search in: LocalMachine_32 
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"); 
foreach (String keyName in key.GetSubKeyNames()) 
{ 
    RegistryKey subkey = key.OpenSubKey(keyName); 
    displayName = subkey.GetValue("DisplayName") as string; 
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) 
    { 
     return true; 
    } 
} 

// search in: LocalMachine_64 
key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"); 
foreach (String keyName in key.GetSubKeyNames()) 
{ 
    RegistryKey subkey = key.OpenSubKey(keyName); 
    displayName = subkey.GetValue("DisplayName") as string; 
    if (p_name.Equals(displayName, StringComparison.OrdinalIgnoreCase) == true) 
    { 
     return true; 
    } 
} 
// NOT FOUND 
return false; 

}

+0

これはあなたが望むものではない可能性が最も高いです。これにより、ソフトウェアが**サーバー**にインストールされているかどうかが検出され、Webサイトを使用するユーザーのシステムでは検出されません。 –

関連する問題