The LVM_GETITEMCOUNT message retrieves the number of items in a list view control. You can send this message explicitly or by using the ListView_GetItemCount macro.
LVM_GETITEMCOUNT wParam = 0; lParam = 0;
Returns the number of items.
ListView_GetItemCount