About one and a half year ago (before I kindly got the tip from Dragon to use Sysinternals) I wrote a similar tool in MFC... Sadly I can't find the full code for this right now but I found the C++ part of it that took care of handling the strings output by the DbgOut underlying function:
Code:
// Window Proc override
LRESULT CClientDebugOutDlg::WindowProc(UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_COPYDATA:
{
// Dispatch client Message
COPYDATASTRUCT* pcds = (COPYDATASTRUCT*)lParam;
if (pcds->dwData == 0)
{
// convert 8-byte char to 16-byte wchar_t
LPCSTR msg = (LPCSTR)pcds->lpData;
LPCWSTR w_msg = CA2W(msg);
handleClientDbgMessage(w_msg);
}
else if (pcds->dwData == 0xFEFF)
{
// 16-byte char
LPCWSTR msg = (LPCWSTR)pcds->lpData;
handleClientDbgMessage(msg);
}
}
break;
}
// Default Return
return CDialogEx::WindowProc(msg, wParam, lParam);
}
void CClientDebugOutDlg::handleClientDbgMessage(std::wstring message /*alternatively: const wchar_t* message*/)
{
// Handle the message here
}
Be aware that this code was used within a
Unicode MFC environment. You can copy paste this into any MFC Unicode project by overriding this WndProc handler in your Dialog class.
You can easily make a standalone version of that using
To view the content, you need to sign in or register
WINAPI function and implement the case switch into your custom WndProc. If you're using MBSC instead of Unicode you'd need
To view the content, you need to sign in or register
for the other case.
If you prefer C# you could also do this via
To view the content, you need to sign in or register
.
Might help someone to make tools...
Edit:
And ofc the window handle must be created with the wnd class "Client DebugOut Window" and the wnd caption "Client DebugOutput 20020805"