I have a function in an IUnknown
-derived COM interface:
HRESULT GetPassword( [in] long bufferLength, [out] WCHAR* buffer );
and the contract is that the implementation should check whether the buffer is large enough to store the string being retrieved. If the buffer is large enough the string is copied and S_OK
is returned, otherwise the function will return an error indication.
However I can't find a suitable HRESULT
value for that. E_UNEXPECTED
seems quite dumb and unhelpful. The closest I found is DISP_E_BUFFERTOOSMALL
but looks like it is for IDispatch
-derived interfaces only.
Which HRESULT
should I returned if a buffer provided is too small?