Vb6 Get installed programs列出32位和64位程序

Vb6 Get installed programs列出32位和64位程序,vb6,registry,64-bit,32bit-64bit,Vb6,Registry,64 Bit,32bit 64bit,下面是我的完整代码,它获取安装在PC上的程序列表。但是,当应用程序在64位PC上运行时,“SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\”注册表将由于注册表重定向而自动引用“SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”。但是我想把所有的程序都安装在电脑上,所以我想我必须同时访问64位和32位的配置单元。那么,我如何访问64位配置单元和32位的所有已安装程序

下面是我的完整代码,它获取安装在PC上的程序列表。但是,当应用程序在64位PC上运行时,“SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\”注册表将由于注册表重定向而自动引用“SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall”。但是我想把所有的程序都安装在电脑上,所以我想我必须同时访问64位和32位的配置单元。那么,我如何访问64位配置单元和32位的所有已安装程序,或者有没有其他技巧可以达到同样的效果?下面是我现有的代码

Option Explicit


Dim StrComputer As String
Dim sCompName As String

Dim sFileName As String

Function GetAddRemove(sComp)
  'Function credit to Torgeir Bakken
  Dim cnt, oReg, sBaseKey, iRC, aSubKeys
  Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
              sComp & "/root/default:StdRegProv")
  sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
  iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)

  Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay

  For Each sKey In aSubKeys
    iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)
    If iRC <> 0 Then
      oReg.GetStringValue HKLM, sBaseKey & sKey, "QuietDisplayName", sValue
    End If
    If sValue <> "" Then
      iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, _
                                "DisplayVersion", sVersion)
      If sVersion <> "" Then
        sValue = sValue & ",Ver: " & sVersion
      Else
        sValue = sValue
      End If
      sTmp = sTmp & sValue & vbCrLf
    cnt = cnt + 1
    End If
  Next
  sTmp = BubbleSort(sTmp)
  GetAddRemove = "INSTALLED SOFTWARE (" & cnt & ") - " & sCompName & _
                 " - " & Now() & vbCrLf & vbCrLf & sTmp
End Function

Function BubbleSort(sTmp)
  'cheapo bubble sort
  Dim aTmp, i, j, temp
  aTmp = Split(sTmp, vbCrLf)
  For i = UBound(aTmp) - 1 To 0 Step -1
    For j = 0 To i - 1
      If LCase(aTmp(j)) > LCase(aTmp(j + 1)) Then
        temp = aTmp(j + 1)
        aTmp(j + 1) = aTmp(j)
        aTmp(j) = temp
      End If
    Next
  Next
  BubbleSort = Join(aTmp, vbCrLf)
End Function

Function WriteFile(sData, sFileName)
 Dim intFile As Integer
  Dim strFile As String
  strFile = sFileName
  intFile = FreeFile
  Open strFile For Output As #intFile
    Print #intFile, sData
  Close #intFile
End Function

Private Sub Form_Load()
StrComputer = "."
sFileName = "D:\desktop\ins.txt"
Dim s As String
s = GetAddRemove(".")
Call WriteFile(s, sFileName)
End Sub
选项显式
作为字符串的Dim STRC计算机
Dim sCompName作为字符串
将sFileName设置为字符串
函数GetAddRemove(sComp)
“Torgeir Bakken的功劳
Dim cnt、oReg、sBaseKey、iRC、aSubKeys
常数HKLM=&H80000002'HKEY\U本地\U机器
设置oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\”&_
sComp&“/root/default:StdRegProv”)
sBaseKey=“软件\Microsoft\Windows\CurrentVersion\Uninstall\”
iRC=oReg.EnumKey(HKLM、sBaseKey、ASUBKEY)
Dim sKey、sValue、sTmp、sVersion、sDateValue、sYr、sMth、sDay
对于aSubKeys中的每个sKey
iRC=oReg.GetStringValue(HKLM、sBaseKey和sKey,“显示名称”,sValue)
如果iRC为0,则
oReg.GetStringValue HKLM,sBaseKey&sKey,“QuietDisplayName”,sValue
如果结束
如果值为“”,则
iRC=oReg.GetStringValue(HKLM、sBaseKey和sKey、_
“显示版本”,sVersion)
如果版本为“”,则
sValue=sValue&“,Ver:”&sVersion
其他的
S值=S值
如果结束
sTmp=sTmp&sValue&vbCrLf
cnt=cnt+1
如果结束
下一个
sTmp=气泡运动(sTmp)
GetAddRemove=“已安装的软件(“&cnt&”)-”&sCompName&_
“-”&Now()&vbCrLf&vbCrLf&sTmp
端函数
函数BubbleSort(sTmp)
“便宜的泡泡型
调暗aTmp,i,j,温度
aTmp=拆分(sTmp、vbCrLf)
对于i=UBound(aTmp)-1到0步骤-1
对于j=0到i-1
如果LCase(aTmp(j))>LCase(aTmp(j+1)),那么
温度=aTmp(j+1)
aTmp(j+1)=aTmp(j)
aTmp(j)=温度
如果结束
下一个
下一个
BubbleSort=Join(aTmp、vbCrLf)
端函数
函数WriteFile(sData,sFileName)
将文件设置为整数
作为字符串的Dim strFile
strFile=sFileName
intFile=FreeFile
打开strFile以作为#intFile输出
打印#intFile,sData
关闭#intFile
端函数
专用子表单_加载()
StrComputer=“”
sFileName=“D:\desktop\ins.txt”
像线一样变暗
s=GetAddRemove(“.”)
调用WriteFile(s,sFileName)
端接头

请参见
不要虚拟化

C:\Users\User>reg flags /?

REG FLAGS KeyName [QUERY |
                   SET [DONT_VIRTUALIZE] [DONT_SILENT_FAIL] [RECURSE_FLAG]]

  Keyname    "HKLM\Software"[\SubKey] (Restricted to these keys on
        local machine only).
    SubKey   The full name of a registry key under HKLM\Software.
  DONT_VIRTUALIZE DONT_SILENT_FAIL RECURSE_FLAG
    Used with SET; flags specified on the command line will be set,
        while those not specified will be cleared.

Examples:

  REG FLAGS HKLM\Software\MyCo\MyApp QUERY
    Displays the current flags of the key MyApp.

  REG FLAGS HKLM\Software\MyCo\MyApp SET DONT_VIRTUALIZE /s
    Sets the DONT_VIRTUALIZE flag (and clears DONT_SILENT_FAIL and
    RECURSE_FLAG) on MyApp and all its subkeys
开始-所有程序-附件-右键单击命令提示符并选择以管理员身份运行。键入(或通过在命令提示窗口中单击鼠标右键并选择“粘贴”来复制和粘贴)。表格格式的类型

wmic /output:"%userprofile%\desktop\WindowsInstaller.html" product get /format:htable
或者以某种形式

wmic /output:"%userprofile%\desktop\WindowsInstaller.html" product get /format:hform
它将在桌面上创建一个html文件

这不是一个完整的列表。这是仅随Windows Installer安装的产品。没有什么特性适合所有的东西

然而,正如我在上一篇文章中所说,几乎所有的东西都列在注册表中

所以要在命令提示符中查看它

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s
或者在文件中

reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /s>"%userprofile%\desktop\WindowsUninstall.txt"
以不同的格式在记事本中查看

单击开始-所有程序-附件-右键单击命令提示符并选择以管理员身份运行。键入Regedit并导航到

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
右键单击卸载键并选择导出。如果另存为reg文件(还有文本文件,它们的文本格式略有不同),则需要右键单击该文件并选择“编辑”以查看该文件

要查看Windows更新

wmic /output:"%userprofile%\desktop\WindowsUpdate.html" qfe  get /format:htable
.