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

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
static partial class Win32_Core {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public const int
   SW_SHOWMAXIMIZED = 3;

public const uint
   STD_OUTPUT_HANDLE    = unchecked((uint)-11),
   MB_ICONERROR         = 0x00000010,
   MB_YESNO             = 0x00000004,
   MB_OK                = 0x00000000,
   MB_SYSTEMMODAL       = 0x00001000,
   IDYES                = 6,
   CP_ACP               = 0,
   WC_NO_BEST_FIT_CHARS = 0x00000400;

public const ushort
   PROCESSOR_ARCHITECTURE_AMD64  = 9,
   PROCESSOR_ARCHITECTURE_ARM    = 5,
   PROCESSOR_ARCHITECTURE_IA64   = 6,
   PROCESSOR_ARCHITECTURE_INTEL  = 0,
   PROCESSOR_ARCHITECTURE_UNKNOWN= 0xFFFF;

public static readonly IntPtr
   INVALID_HANDLE_VALUE = (IntPtr)(-1),
   IDC_WAIT             = (IntPtr)(ushort)32514;

public const UInt32
   ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID= 0x00000004,
   ACTCTX_FLAG_RESOURCE_NAME_VALID     = 0x00000008,
   ACTCTX_FLAG_SET_PROCESS_DEFAULT     = 0x00000010;

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

[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_INFO
{
   public   ushort   wProcessorArchitecture;
   private  ushort   wReserved;
   public   uint     dwPageSize;
   public   IntPtr   lpMinimumApplicationAddress;
   public   IntPtr   lpMaximumApplicationAddress;
   public   UIntPtr  dwActiveProcessorMask;
   public   uint     dwNumberOfProcessors;
   public   uint     dwProcessorType;
   public   uint     dwAllocationGranularity;
   public   ushort   wProcessorLevel;
   public   ushort   wProcessorRevision;
}

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

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

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

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

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

[DllImport("Kernel32.dll",ExactSpelling=true)]
public static extern void GetSystemInfo(out SYSTEM_INFO systemInfo);

[DllImport("Kernel32.dll",ExactSpelling=true)]
public static extern void GetNativeSystemInfo(out SYSTEM_INFO systemInfo);

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

[DllImport("Kernel32.dll",CharSet=CharSet.Unicode,SetLastError=true)]
public static extern int MoveFile(string strExistingFileName,string strNewFileName);

[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("Kernel32.dll",CharSet=CharSet.Unicode)]
public static extern void OutputDebugString(string strOutputString);

[DllImport("Kernel32.dll",CharSet=CharSet.Unicode,SetLastError=true)]
public static extern IntPtr LoadLibrary(string fileName);

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

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

[DllImport("User32.dll",CharSet=CharSet.Unicode,SetLastError=true)]
public static extern IntPtr LoadCursor(IntPtr hInstance,IntPtr ipCursorName);

[DllImport("User32.dll",ExactSpelling=true,SetLastError=true)]
public static extern IntPtr SetCursor(IntPtr hCursor);

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // Win32_Core
//**************************************************************************************************

} // CommonHelpers (.WASM)
