How do I write to the VB6 immediate window from C+

2019-09-08 06:12发布

问题:

I have developed a C++ based COM object to use it in a VB6 application. Now I need to add some logging to catch some of the bugs. I discovered from the answer to 'How to debug COM object in Visual Studio 6.0' question that I can use the OutputDebugString function. But is it possible to write to the VB6 immediate window somehow?

回答1:

Rather than attempting to write to the immediate window, it would be generally more useful to use DebugView from Sysinternals (now part of Microsoft technet):

DebugView is an application that lets you monitor debug output on your local system, or any computer on the network that you can reach via TCP/IP. It is capable of displaying both kernel-mode and Win32 debug output, so you don't need a debugger to catch the debug output your applications or device drivers generate, nor do you need to modify your applications or drivers to use non-standard debug output APIs.

You can use this during development and also in production.

Under Windows 2000, XP, Server 2003 and Vista DebugView will capture:

  • Win32 OutputDebugString
  • Kernel-mode DbgPrint
  • All kernel-mode variants of DbgPrint implemented in Windows XP and Server 2003


回答2:

I don't think you can write direct to it but you can use a COM event that just contains a debug.print call.