开发者

Why the following c++ snippet gives exception?

开发者 https://www.devze.com 2023-01-14 17:42 出处:网络
VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;; ... WriteFile( hHand开发者_运维技巧le, pVih, sizeof(VIDEOINFOHEADER), NULL, NULL );
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?

0

精彩评论

暂无评论...
验证码 换一张
取 消