If the code above is complete then it looks like you have not specified the
. 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
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
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
too early. I recommend you moving this line further down after