All Frameworks Class Hierarchy This Framework Indexes
typedef int HRESULTReturn type for the QueryInterface method, and for most interface methods.
IMyInterface * pIMyInterface = NULL ; HRESULT rc = pIMyOtherInterface->QueryInterface(IID_IMyInterface,(void**) &pIMyInterface); //Test with SUCCEEDED macro: if ( SUCCEEDED(rc) ) { // In this case, rc is S_OK // pIMyInterface is valid .... } //Test with FAILED macro if ( FAILED(rc) ) { // In this case, rc is E_NOINTERFACE or E_UNEXPECTED // pIMyInterface is not valid }
IMyInterface * pIMyInterface = NULL ; HRESULT rc = pIMyOtherInterface->QueryInterface(IID_IMyInterface,(void**) &pIMyInterface); if ( SUCCEEDED(rc) ) { // rc = S_OK rc = pIMyInterface->Method(); // Test with SUCCEEDED macro if ( SUCCEEDED(rc) ) { // In this case, rc is S_OK or S_FALSE // You can directly test the rc value if ( S_FALSE == rc ) { ... }else { .... } } // Test with FAILED macro if ( FAILED(rc) ) { // In this case, rc is E_xxxxx // You can directly test the rc value, if ( E_FAIL == rc ) { .... } .... } }
Copyright © 2003, Dassault Systèmes. All rights reserved.