Sends a string to the debugger for display.
[DllImport("kernel32.dll")]
static extern void OutputDebugString(string lpOutputString);
<DllImport("kernel32.dll")> _
Shared Sub OutputDebugString(ByVal lpOutputString As String)
End Sub
Or (as in VB 6)
Public Declare Sub OutputDebugString Lib "kernel32" Alias _
"OutputDebugStringA" (ByVal lpOutputString As String)
None.
None.
Get DebugView here (http://www.sysinternals.com/Utilities/DebugView.html) to display the output of OutputDebugString.
This C# example extends the OutputDebugString(...) with variable arguments:
public static void OutputDebugStringVarArg(
string format,
params object[] args)
{
try
{
OutputDebugString(string.Format(format, args));
}
catch (Exception)
{
return;
}
}
Now run the function as follows: OutputDebugStringVarArg("It is {0} past {1}", new object[] {5,10 });
Get OutputDebugString function implementation that accepts variable number of arguments like printf here (http://www.go4expert.com/forums/showthread.php?t=871)
1. Create a new C# windows console application project.
2. Add the following
using System.Runtime.InteropServices;
below
using System.Text;
3. Add the following as the first statement of the main function.
OutputDebugString("OutputDebugString Successfully executed");
Now execute the program with DebugView Open
System.Diagnostics.Debug.WriteLine
System.Diagnostics.Debugger.Log