When I use the below function to get the list of installed software in a computer, I am getting the product name as "?[" or some other junk character when the DisplayName is empty in the registery
Any help is appreciated.
Thanks
Jambai
Code:
Private Function GetAddRemove(sComp) As String
Dim cnt, oReg, sBaseKey, iRC, aSubKeys, iPN, ix
Dim sCompName As String
Const HKEY_LOCAL_MACHINE = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
sComp & "/root/default:StdRegProv")
sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
iRC = oReg.EnumKey(HKEY_LOCAL_MACHINE, sBaseKey, aSubKeys)
Dim sKey, sValue, sTmp, sVersion, sDateValue, sYr, sMth, sDay, sPublisher, psValue
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SWI")
Dim strDeviceID, strProductName As String
For Each sKey In aSubKeys
On Error Resume Next
[COLOR=red]iRC = oReg.GetStringValue(HKEY_LOCAL_MACHINE, sBaseKey & sKey, "DisplayName", sValue)[/color]
iPN = oReg.GetStringValue(HKEY_LOCAL_MACHINE, sBaseKey & sKey, "Publisher", sPublisher)
If iRC <> 0 Then
oReg.GetStringValue HKEY_LOCAL_MACHINE, sBaseKey & sKey, "QuietDisplayName", sValue
End If
''Code to insert the values into DB
cnt = cnt + 1
End If
Next
End Function
Any help is appreciated.
Thanks
Jambai