まんまです。
FormatMessageA とか、その辺を使えばいいのかな?と思ったのですが、
すげー面倒そうなので、他を調べたら出てきました。
動いたのでメモ。
/// <summary> /// 指定されたエラーコードから、エラーを説明するメッセージと16進数表現を返します。 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string FormatMessage(int code) { byte[] b = BitConverter.GetBytes(code); Array.Reverse(b);//リトルエンディアンなので string bs = "0x" + BitConverter.ToString(b, 0).Replace("-", ""); return string.Format("{0}({1})", new System.ComponentModel.Win32Exception(code).Message, bs); }