【发布时间】:2011-08-16 05:08:32
【问题描述】:
我正在尝试为 winapi 函数 GetWindowText 制作包装器。
函数返回 std::wstring 但我不知道如何处理发生错误的位置。我返回 NULL 但我知道这是错误的。
std::wstring GetWindowText(HWND handle)
{
const int size = 1024;
TCHAR wnd_text[size] = {0};
HRESULT hr = ::GetWindowText(handle,
wnd_text, size);
if(SUCCEEDED(hr))
return std::wstring(wnd_text);
else
return NULL;
}
【问题讨论】:
标签: c++ exception-handling error-handling