我不明白这一点:((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->rcSource = rc;
导致(WM_MEDIA_TYPE *)VideoMediaType成为invaid。当代码块的其余部分似乎没有问题时。
WM_MEDIA_TYPE* VideoMediaType = NULL;
VideoMediaType = (WM_MEDIA_TYPE*) new BYTE[MediaType];
Status = VideoMediaProps->GetMediaType(VideoMediaType, &MediaType);
RECT rc;
rc.left = 0;
rc.top = 0;
rc.right = 640;
rc.bottom = 480;
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->rcSource = rc; //<--Causing the issue.
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->rcTarget = rc;
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->dwBitRate = BitRate;
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->AvgTimePerFrame = ( (LONGLONG) 10000000 ) / ( (LONGLONG) 30 );
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->bmiHeader.biHeight = GetSystemMetrics(SM_CYSCREEN);
((WMVIDEOINFOHEADER*)&VideoMediaType->pbFormat)->bmiHeader.biWidth = GetSystemMetrics(SM_CXSCREEN);
无论我把这行放在哪里,一旦调试器在调试模式下进入该行,VideoMediaType&#39;变得无效。如果我注释掉该行,则指针保持有效并且程序按预期执行。