OutputDebugStringW function (debugapi.h)

Sends a string to the debugger for display.

Important  In the past, the operating system did not output Unicode strings via OutputDebugStringW and instead only output ASCII strings. To force OutputDebugStringW to correctly output Unicode strings, debuggers are required to call WaitForDebugEventEx to opt into the new behavior. On calling WaitForDebugEventEx, the operating system will know that the debugger supports Unicode and is specifically opting into receiving Unicode strings.
 

Syntax

void OutputDebugStringW(
  LPCWSTR lpOutputString
);

Parameters

lpOutputString

The null-terminated string to be displayed.

Return value

None

Remarks

If the application has no debugger, the system debugger displays the string if the filter mask allows it. (Note that this function calls the DbgPrint function to display the string. For details on how the filter mask controls what the system debugger displays, see the DbgPrint function in the Windows Driver Kit (WDK) on MSDN.) If the application has no debugger and the system debugger is not active, OutputDebugString does nothing.Prior to Windows Vista:  The system debugger does not filter content.

OutputDebugStringW converts the specified string based on the current system locale information and passes it to OutputDebugStringA to be displayed. As a result, some Unicode characters may not be displayed correctly.

Applications should send very minimal debug output and provide a way for the user to enable or disable its use. To provide more detailed tracing, see Event Tracing.

Visual Studio has changed how it handles the display of these strings throughout its revision history. Refer to the Visual Studio documentation for details of how your version deals with this.

Note

The debugapi.h header defines OutputDebugString as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

   
Minimum supported client Windows XP [desktop apps | UWP apps]
Minimum supported server Windows Server 2003 [desktop apps | UWP apps]
Target Platform Windows
Header debugapi.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See also

Communicating with the Debugger

Debugging Functions