Why the following c++ snippet gives exception?
VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;;
...
WriteFile( hHand开发者_运维技巧le, pVih, sizeof(VIDEOINFOHEADER), NULL, NULL );
Through debugging I found WriteFile
reports exception, how to solve it?
Probably, pmtConfig->pbFormat is NULL or invalid. Give us more details on exception, please.
Is pVih
initialized? If not, that's your problem.
follow up
Since pVih is initialized, I looked at the documentation. The fourth parameter, lpNumberOfBytesWritten, cannot be NULL if the fifth parameter, lpOverlapped, is NULL. Provide a pointer to a variable to accept the number of bytes written.
second follow up
Is pmtConfig->pbFormat
properly pointing to a VIDEOINFOHEADER
?
精彩评论