C言語におけるOutputDebugString関数の使用方法

OutputDebugString関数はWindows APIの1つで、デバッグ情報を出力する関数です。プロトタイプは以下になります。

void OutputDebugStringA(LPCSTR lpOutputString);
void OutputDebugStringW(LPCWSTR lpOutputString);

lpOutputString パラメーターは、デバッグ情報を出力する文字列で、ASCII文字またはワイド文字のいずれかです。

1. OutputDebugString関数の使用手順を以下に示します。

  1. Windows API関数が使えるように、コード内にWindows.hヘッダファイルを含めます。
#include <Windows.h>
  1. デバッグ情報を文字列形式にしてOutputDebugString関数へ引数として渡す
OutputDebugStringA("This is a debug message.");

または

OutputDebugStringW(L"This is a debug message.");
  1. Visual Studioのデバッグモードのように、OutputDebugString関数を用いたアプリケーションでデバッガーを起動します。
  2. デバッガーでデバッグ情報の出力を確認する。Visual Studioでは、[出力ウィンドウ]を使用してデバッグ情報を確認できます。
bannerAds