Which current HRESULT constant will cause the SUCCEEDED () macro to fail?

Definition of SUCCEEDED (): #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)

Background: when the Ok button is pressed in the dialog box, I need to return the value HRESULT hrso that SUCCEEDED(hr)it is true. If I click Cancel, I need to return a negative value. I could use bools, but this will break the existing template (usually the hr values ​​come from the depths of the system dlls). So, I know that I can return S_OKto OK, but what can I return to Cancel? I could have just return (HRESULT)-1;, but there should be a better way - some HRESULT constant, which has a negative value and represents a general failure. S_FALSEnot so, for him the value is defined as 1L.

Please help me find the right constant.

+3
source share
4 answers

Typical values ​​are shown here: http://msdn.microsoft.com/en-us/library/aa378137(VS.85).aspx

E_FAIL or E_ABORT seem most obvious.

+3
source

Maybe E_ABORT

+6
source

E_FAIL E_ABORT. , , SUCCEEDED(hr), S_OK.

+6

, E_ABORT ( E_FAIL) , , MAKE_HRESULT() HRESULT_FROM_WIN32() Win32, , .

HRESULT_FROM_WIN32( ERROR_CANCELLED)?

+3

Source: https://habr.com/ru/post/1740347/


All Articles