Click here to Skip to main content
15,882,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

Using the QueryInterface like the code below

C++
hr = m_pPISourceFilter->QueryInterface(IID_IFileOffset,(void **)&m_pFileOffset);


I always check if it fails like this

C++
if (FAILED(hr)) {
    ReportError(_T("Failed to initialize the filter (FileOffset)."),hr);
    return FALSE;
		
}


Instead of returning back a FALSE value to the caller for any cleanup procedures, the application crashes.

To test this code, the DirectShow filter is not registered and consequently the Interface IID_IFileOffice does not exist.

What seems to be wrong here ?

Regards,

What I have tried:

To catch the error using FAILED(hr) or SUCCEEDED(hr)
Posted
Comments
[no name] 14-Feb-16 7:40am    
And you are sure that "m_pPISourceFilter" is valid?
sdancer75 15-Feb-16 10:49am    
Νο m_pPISourceFilter is not valid (old COM build), but the question is why it crashes while it should return to caller. I run this only in release mode to user's machine. I suspect that it crashes somewhere inside the caller...
[no name] 15-Feb-16 11:30am    
How you get m_pPISourceFilter? In case m_pPISourceFilter is NULL you have to correct this first.
sdancer75 16-Feb-16 5:45am    
m_pPISourceFilter is the pointer result of a previous QueryInterface in a previous step that I have not shown here. In case of problem then the previous if (FAILED(hr)) should have catch this right ? In this case should never come to this step.
[no name] 16-Feb-16 5:48am    
Yes FAILED(hr) should have catched it. Anyway I would inspect it with Debugger if possible. With what you are developing? VS, Borland?

Maybe this helps, but pay Attention, my browser tells me the site has a Problem ....
https://www.doom9.org/showthread.php?p=1646451[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900