[API]
LVITEM
SendMessageA
SendMessageW

[INCLUDE]
Unicode
ListView_Item_Count

[CODE]
Public Sub ListView_Item_SelectByImage_Dual(ByVal hWndListView As Long, ByVal ImageID1 As Long, ByVal ImageID2 As Long)
  Dim xLong1 As Long
  Dim xType1 As LVITEM

  xType1.mask = &HA&
  xType1.stateMask = &H2&
  
  If IsUnicode Then
    For xLong1 = 0& To ListView_Item_Count(hWndListView) - 1&
      xType1.iItem = xLong1
      If SendMessageW(hWndListView, &H104B&, xLong1, xType1) = 0& Then
        xType1.state = 0&
        Call SendMessageW(hWndListView, &H102B&, xLong1, xType1)
        ElseIf xType1.iImage = ImageID1 Or xType1.iImage = ImageID2 Then
        If Not xType1.state = 2& Then
          xType1.state = 2&
          Call SendMessageW(hWndListView, &H102B&, xLong1, xType1)
          End If
        ElseIf xType1.state = 2& Then
        xType1.state = 0&
        Call SendMessageW(hWndListView, &H102B&, xLong1, xType1)
        End If
      Next
    Else
    For xLong1 = 0& To ListView_Item_Count(hWndListView) - 1&
      xType1.iItem = xLong1
      If SendMessageA(hWndListView, &H1005&, xLong1, xType1) = 0& Then
        xType1.state = 0&
        Call SendMessageA(hWndListView, &H102B&, xLong1, xType1)
        ElseIf xType1.iImage = ImageID1 Or xType1.iImage = ImageID2 Then
        If Not xType1.state = 2& Then
          xType1.state = 2&
          Call SendMessageA(hWndListView, &H102B&, xLong1, xType1)
          End If
        ElseIf xType1.state = 2& Then
        xType1.state = 0&
        Call SendMessageA(hWndListView, &H102B&, xLong1, xType1)
        End If
      Next
    End If
  End Sub