我是編程新手。我得到了一個虛擬會議網站。現在我需要修改該網站。如何檢測Windows中是否安裝了特定的軟件?
當用戶登錄到會議站點時,它必須檢測他的系統是否在他的系統中安裝了特定軟件(該軟件用於進行視頻呼叫,它使用ActiveX對象)。
哪種方法可以檢測系統中已安裝軟件的存在? (坦率地說,我甚至不知道哪種語言最適合用於此目的)
我是編程新手。我得到了一個虛擬會議網站。現在我需要修改該網站。如何檢測Windows中是否安裝了特定的軟件?
當用戶登錄到會議站點時,它必須檢測他的系統是否在他的系統中安裝了特定軟件(該軟件用於進行視頻呼叫,它使用ActiveX對象)。
哪種方法可以檢測系統中已安裝軟件的存在? (坦率地說,我甚至不知道哪種語言最適合用於此目的)
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;
}
由於您無法訪問系統,因此無法真正檢測到這一點。您的Web應用程序應該簡單地嘗試創建該ActiveX的實例,並在用戶失敗時向用戶顯示消息。
謝謝大家。但我在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;
}
這很可能不是你想要的。這可以檢測到,如果軟件安裝在**服務器上**,而不是在使用您的網站的用戶系統上! –
-1:幸運的是,它是不可能從一個Web應用程序訪問註冊表。他不想檢查服務器計算機上的ActiveX是否存在,但是在客戶端計算機上。 –
@Naresh thandu謝謝!你的代碼真的幫了很多 – kairav