windows - Which HRESULT to return when a buffer provided is too small? -


i have function in iunknown-derived com interface:

hresult getpassword( [in] long bufferlength, [out] wchar* buffer ); 

and contract implementation should check whether buffer large enough store string being retrieved. if buffer large enough string copied , s_ok returned, otherwise function return error indication.

however can't find suitable hresult value that. e_unexpected seems quite dumb , unhelpful. closest found disp_e_buffertoosmall looks idispatch-derived interfaces only.

which hresult should returned if buffer provided small?

you can't return disp_e_* errors, not implementing idispatch. e_invalidarg correct here, unambiguous doesn't happen often. implement isupporterrorinfo generate error messages, atl makes trivial error() method.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -