using System;
// ElementaryExtensions API:
using ElementaryExtensions;
namespace MiscellaneousDemo {
//**************************************************************************************************
static partial class Program {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Accessing class.
///
static void Win32ErrorDemo()
{
int nWin32Error;
ЄConsole.PrintDialogCaption(
"Input Win32 error codes to extract system messages:" );
for (;;)
{
ЄConsole.Print();
if (!InputErrorCode(out nWin32Error))
break;
string strErrorMessage=
ЄWin32Error.ErrorCodeToMessage(nWin32Error,true);
if (strErrorMessage!=null)
ЄConsole.PrintExpressive(strErrorMessage);
else
ЄConsole.PrintFaint("System message not found by code.");
}
}
///
/// Helper function, to input Win32 error code.
///
static bool InputErrorCode(out int nWin32Error)
{
nWin32Error=0;
string strCheckedInput=
ЄConsole.InputString
(
"Win32 error code (dec.)",
delegate (string strInput)
{
int nNumber;
return ЄValueParser.TryParseInt32Invariant(strInput,out nNumber) &&
nNumber>=0;
}
);
if (strCheckedInput==null)
return false;
nWin32Error=ЄValueParser.ParseInt32Invariant(strCheckedInput);
return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // Program
//**************************************************************************************************
} // MiscellaneousDemo