ok everyone seems to be asking about the icon thing...
its really cake to do, and I wanted that feature as well so I put it in...
now as perfect as this solution seemed (unghhhhh!), it wasnt really what i wanted after all.. but chris u definately put me in the right path.. like sum1 mentioned B4, what i really wanted was the path to the executables, and didnt want bundles (such as office, or adobe cs3), but rather an itemized account of the exe's in those bundles (word, excel, ect.).. so using your structure (nicely done with the Ienum, i guess i dont know as much as i thought i did) i will search the start menu, and program files folder, and possibly system32 for any & all exe. when i finish, following tradition, i will post in new thread. Now for the icon matter this is how i did it:
in the properties region add:
vb Code:
Private _IconPath As String = String.Empty
''' <summary>
''' If this program specifies an icon file, it's path will be returned
''' </summary>
Public Property IconPath() As String
Get
Return _IconPath
End Get
Set(ByVal value As String)
_IconPath = value
End Set
End Property
in the constructors region change second sub to:
vb Code:
Public Sub New(ByVal ProgramDisplayName As String, ByVal ProgramParentDisplayName As String, ByVal IsProgramUpdate As Boolean, ByVal ProgramVersion As String, ByVal ProgramIconPath As String)
Me.DisplayName = ProgramDisplayName
Me.ParentDisplayName = ProgramParentDisplayName
Me.IsUpdate = IsProgramUpdate
Me.Version = ProgramVersion
Me.IconPath = ProgramIconPath
End Sub
in the GetUserInstallerKeyPrograms function edit to the following:
vb Code:
If Not CInt(UserDataProgramKey.GetValue("SystemComponent", 0)) = 1 Then
Dim Name As String = CStr(CuInstallerKey.OpenSubKey(CuProductGuid).GetValue("ProductName", String.Empty))
Dim ProgVersion As String = String.Empty
Dim ProgIcon As String = String.Empty
Try
ProgVersion = CStr(UserDataProgramKey.GetValue("DisplayVersion", String.Empty))
ProgIcon = CStr(UserDataProgramKey.GetValue("DisplayIcon", String.Empty))
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
If Not Name = String.Empty AndAlso Not IsProgramInList(Name, ExistingProgramList) Then
ExistingProgramList.Add(New InstalledProgram(Name))
ProductFound = True
End If
End If
in the GetUninstallKeyPrograms function edit to the following:
vb Code:
If IncludeUpdates Then
'Add the program to our list if we are including updates in this search
Dim Name As String = CStr(CurrentSubKey.GetValue("DisplayName", String.Empty))
Dim IconP As String = CStr(CurrentSubKey.GetValue("DisplayIcon", String.Empty))
If Not Name = String.Empty AndAlso Not IsProgramInList(Name, ExistingProgramList) Then
ExistingProgramList.Add(New InstalledProgram(Name, CStr(CurrentSubKey.GetValue("ParentDisplayName", String.Empty)), True, ProgVersion, IconP))
End If
End If
and still in the GetUninstallKeyPrograms function edit to the following:
vb Code:
If UninstallStringExists Then
Dim Name As String = CStr(CurrentSubKey.GetValue("DisplayName", String.Empty))
Dim IconP As String = CStr(CurrentSubKey.GetValue("DisplayIcon", String.Empty))
If Not Name = String.Empty AndAlso Not IsProgramInList(Name, ExistingProgramList) Then
If Not IconP = String.Empty Then
End If
ExistingProgramList.Add(New InstalledProgram(Name, CStr(CurrentSubKey.GetValue("ParentDisplayName", String.Empty)), False, ProgVersion, IconP))
End If
End If
and still in the GetUninstallKeyPrograms function edit to the following:
vb Code:
Else 'If WindowsInstaller
Dim ProgVersion As String = String.Empty
Dim Name As String = String.Empty
Dim FoundName As Boolean = False
Dim IconP As String = String.Empty
Try
Dim MsiKeyName As String = GetInstallerKeyNameFromGuid(SubKeyName)
Dim CrGuidKey As RegistryKey = ClassesKey.OpenSubKey(MsiKeyName)
If Not CrGuidKey Is Nothing Then
Name = CStr(CrGuidKey.GetValue("ProductName", String.Empty))
IconP = CStr(CrGuidKey.GetValue("DisplayIcon", String.Empty))
End If
Catch ex As Exception
Debug.WriteLine(SubKeyName & " - " & ex.Message)
End Try
Try
ProgVersion = CStr(CurrentSubKey.GetValue("DisplayVersion", String.Empty))
IconP = CStr(CurrentSubKey.GetValue("DisplayIcon", String.Empty))
Catch ex As Exception
Debug.WriteLine(ex.Message)
End Try
If Not Name = String.Empty AndAlso Not IsProgramInList(Name, ExistingProgramList) Then
ExistingProgramList.Add(New InstalledProgram(Name, CStr(CurrentSubKey.GetValue("ParentDisplayName", String.Empty)), False, ProgVersion, IconP))
End If
End If
Now in your form get the icons as follows:
vb Code:
Private Sub GetProgramsFinished(ByVal InstalledPrograms As List(Of InstalledProgram))
If Not InstalledPrograms Is Nothing Then
For i As Integer = 0 To InstalledPrograms.Count - 1
If InstalledPrograms(i).IsUpdate = False Then
Dim theIcon As Icon
Dim theIconPath As String
Try
If Not InstalledPrograms(i).IconPath = Nothing Then
If InstalledPrograms(i).IconPath.IndexOf(",") > 0 Then
theIconPath = InstalledPrograms(i).IconPath.Substring(0, InstalledPrograms(i).IconPath.IndexOf(","))
Else
theIconPath = InstalledPrograms(i).IconPath
End If
theIcon = System.Drawing.Icon.ExtractAssociatedIcon(theIconPath)
Else
theIcon = My.Resources.error_icon1
End If
Catch ex As Exception
theIcon = My.Resources.error_icon1
End Try
ProgDataGridView.Rows.Add("", theIcon, InstalledPrograms(i).DisplayName)
Me.ProgDataGridView.Refresh()
End If
Next
End If
Me.Enabled = True
If ProgDataGridView.Rows.Count = 1 Then
MessageBox.Show("No programs were found - this could be because there were no programs installed on the computer (that is not very likely really though is it)." & vbNewLine & _
"Try again... ", "Ooops", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Else
End If
End Sub
this will get u almost all icons, and puts one in its place where it didnt find an icon. Im not going to perfect this, as im going a slightly different route based on chris's solution... but should help point yall in the right direction...