获取已安装的软件列表
可能的重复:
获取已安装的软件列表
如何使用C获取已安装的应用程序软件列表?我有一个 C# 解决方案。这是 C# 代码:
System Microsoft.Win32
private string Getinstalledsoftware() {
string Software = null;
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey)) {
foreach (string skName in rk.GetSubKeyNames()) {
using (RegistryKey sk = rk.OpenSubKey(skName)) {
try {
if (!(sk.GetValue("DisplayName") == null)) {
if (sk.GetValue("InstallLocation") == null)
Software += sk.GetValue("DisplayName") + " - Install path not known\n";
else
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n";
}
}
catch (Exception ex) {
}
}
}
}
return Software;
}
如何将 C# 代码转换为 C 代码?
Possible Duplicate:
Get Installed software list
How to get installed application software list using C? I have a solution in C#. This is the C# code:
System Microsoft.Win32
private string Getinstalledsoftware() {
string Software = null;
string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
using (RegistryKey rk = Registry.LocalMachine.OpenSubKey(SoftwareKey)) {
foreach (string skName in rk.GetSubKeyNames()) {
using (RegistryKey sk = rk.OpenSubKey(skName)) {
try {
if (!(sk.GetValue("DisplayName") == null)) {
if (sk.GetValue("InstallLocation") == null)
Software += sk.GetValue("DisplayName") + " - Install path not known\n";
else
Software += sk.GetValue("DisplayName") + " - " + sk.GetValue("InstallLocation") + "\n";
}
}
catch (Exception ex) {
}
}
}
}
return Software;
}
How can I convert the C# code into C code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将此处执行的操作映射到其相应的 Windows API 注册表函数和其他字符串操作函数,如果您希望进行翻译。
否则,您可能可以使用 Windows Installer API 直接执行此操作。
以下是使用安装程序 API 转储产品的示例:
ps,您需要链接到 msi.lib/dll 库。
You need to map the operations performed here to their corresponding Windows API registry functions and other string manipulation functions if you wish to perform the translation.
Otherwise you could probably use the Windows Installer API to do this directly.
Here's an example that dumps the products using the installer API:
p.s., you'll need to link to the msi.lib/dll library.
您可以例如:
当然你也可以不进行步骤1,直接进行步骤2。
You could e.g.:
Of course you can also directly move to step 2 without step 1.