转换HWND成LPWSTR?

问题描述

我有以下代码

MessageBox(NULL,NULL,(LPCWSTR)FindWindow(NULL,L"Untitled - Notepad"),MB_OK);

如何使消息框的标题成为记事本的窗口句柄?使用c ++有什么有效而简单的方法吗?

解决方法

此:

HWND hwnd = FindWindowW(NULL,L"Untitled - Notepad");
std::wostringstream ss;
ss << std::hex << hwnd;
std::wstring strTitle = ss.str();
MessageBoxW(NULL,L"Caption message",strTitle.c_str(),MB_OK);