//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static class w32_core {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public const uint
   STD_OUTPUT_HANDLE    = unchecked((uint)-11),
   MB_ICONERROR         = 0x00000010,
   MB_YESNO             = 0x00000004,
   MB_SYSTEMMODAL       = 0x00001000,
   IDYES                = 6,
   CP_ACP               = 0,
   WC_NO_BEST_FIT_CHARS = 0x00000400;
public static readonly IntPtr
   INVALID_HANDLE_VALUE = (IntPtr)(-1);

//==================================================================================================

[DllImport( "Kernel32.dll", ExactSpelling=true )]
public static extern uint GetLastError();

[DllImport( "Kernel32.dll", ExactSpelling=true )]
public static extern void SetLastError( uint dwErrCode );

[DllImport( "Kernel32.dll", ExactSpelling=true )]
public static extern uint GetTickCount();

[DllImport( "Kernel32.dll", CharSet=CharSet.Unicode )]
public static extern void OutputDebugString( string? strOutputString );

[DllImport( "Kernel32.dll", ExactSpelling=true, SetLastError=true )]
public static extern bool TerminateProcess( IntPtr hProcess, uint uExitCode );

[DllImport( "Kernel32.dll", ExactSpelling=true, SetLastError=true )]
public static extern IntPtr GetStdHandle( uint uStdHandle );

[DllImport( "Kernel32.dll", ExactSpelling=true, SetLastError=true )]
public static extern bool Beep( uint dwFreq, uint dwDuration );

[DllImport( "Kernel32.dll", ExactSpelling=true, CharSet=CharSet.Unicode, SetLastError=true )]
public static extern int WideCharToMultiByte(
   uint codePage, uint dwFlags,
   string wideCharStr, int cchWideChar,
   byte[] multiByteStrBuff, int cbMultiByte,
   IntPtr ipDefaultChar, out int usedDefaultChar );

//--------------------------------------------------------------------------------------------------

[DllImport( "User32.dll", CharSet=CharSet.Unicode, SetLastError=true )]
public static extern int MessageBox( IntPtr hWnd, string? strText,
                                     string? strCaption, uint uType );

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // w32_core

} // user_rtx (.wasm)
