If the code above is complete then it looks like you have not specified the
mask
before calling
ListView_GetItem
. This, together with the fact that you haven't "ZeroMemoried" the LI variable means that mask can be anything. If it happens that mask contains
LVIF_TEXT
flag by any chance then you may easily corrupt your memory.
So, the solution in your case will be to comment these three lines like this (what's the purpose of them anyway?):
If you really need to call
ListView_GetItem
you need to specify mask. It is also always a good idea to ZeroMemory the C structs before using them.
On the side note, it looks like that you assigning
nlv=(LPNMLISTVIEW)lParam;
too early. I recommend you moving this line further down after
case LVN_ITEMCHANGED:
line.