From ae33ddfe759f1da95a87df934778bd74eb3557bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 27 Mar 2020 17:13:36 +0100 Subject: [PATCH 01/50] Fixes for ErrHandlingApi --- .../ErrHandlingApiFunctions.cs | 83 +++++++++++++++++-- .../GlobalSuppressions.cs | 9 +- ...NETII.WinApi.Headers.ErrHandlingApi.csproj | 6 +- 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs index 380e3fe2..80774736 100644 --- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Runtime.InteropServices; using System.Text; +using THNETII.InteropServices.Memory; using THNETII.WinApi.Native.WinBase; #if NETSTANDARD1_6 @@ -165,27 +166,97 @@ SYSTEM_ERROR_MODE uMode /// Minimum supported server:Windows Server 2003 [desktop apps | UWP apps] /// /// - /// Microsoft Docs page: FatalAppExit function + /// Microsoft Docs page: FatalAppExitW function /// /// The native library containg the function could not be found. /// Unable to find the entry point for the function in the native library. + /// Error Handling Functions /// - public static void FatalAppExit( - int uAction, - string lpMessageText - ) => FatalAppExitW(uAction, lpMessageText); +#if !NETSTANDARD1_6 + [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] + public static extern +#else + public static +#endif // !NETSTANDARD1_6 + void FatalAppExit( + [In] int uAction, + [In] string lpMessageText + ) +#if !NETSTANDARD1_6 + ; +#else + + { + switch (Marshal.SystemDefaultCharSize) + { + case 1: + FatalAppExitA(uAction, lpMessageText); + break; + case 2: + FatalAppExitW(uAction, lpMessageText); + break; + default: throw new PlatformNotSupportedException(); + } + } +#endif // !NETSTANDARD1_6 + /// [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitA))] public static extern void FatalAppExitA( [In] int uAction, [In, MarshalAs(UnmanagedType.LPStr)] string lpMessageText ); + /// [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, EntryPoint = nameof(FatalAppExitW))] public static extern void FatalAppExitW( [In] int uAction, [In, MarshalAs(UnmanagedType.LPWStr)] string lpMessageText ); + + /// +#if !NETSTANDARD1_6 + [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] + public static extern +#else + public static +#endif // !NETSTANDARD1_6 + void FatalAppExit( + [In] int uAction, + [In] LPCTSTR lpMessageText + ) +#if !NETSTANDARD1_6 + ; +#else + + { + switch (Marshal.SystemDefaultCharSize) + { + case 1: + FatalAppExitA(uAction, Pointer.Create(lpMessageText.Pointer)); + break; + case 2: + FatalAppExitW(uAction, Pointer.Create(lpMessageText.Pointer)); + break; + default: throw new PlatformNotSupportedException(); + } + } +#endif // !NETSTANDARD1_6 + + /// + [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)] + public static extern void FatalAppExitA( + [In] int uAction, + [In] LPCSTR lpMessageText + ); + + + /// + [DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] + public static extern void FatalAppExitW( + [In] int uAction, + [In] LPCWSTR lpMessageText + ); #endregion // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\errhandlingapi.h, line 250 #region GetThreadErrorMode function diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs index 6b57a412..68adb720 100644 --- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/GlobalSuppressions.cs @@ -1,12 +1,13 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. using System.Diagnostics.CodeAnalysis; -[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")] -[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")] [assembly: SuppressMessage("Documentation", "CA1200: Avoid using cref tags with a prefix")] -[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] +[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous reference in cref attribute")] [assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments")] +[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")] +[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] +[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")] diff --git a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj index 5c56517d..5ed2ceab 100644 --- a/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj +++ b/src-native/THNETII.WinApi.Headers.ErrHandlingApi/THNETII.WinApi.Headers.ErrHandlingApi.csproj @@ -1,11 +1,11 @@ - + - 7.2 + 8 netstandard1.6;netstandard2.0 true - CS1591 + $(NoWarn);CS1591;CS0419 THNETII.WinApi.Native.ErrHandlingApi From d66b11e2433a6ef2e5de6e697943eba614cf7d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 27 Mar 2020 17:34:51 +0100 Subject: [PATCH 02/50] Fixes for FileApi --- .../FileApiFunctions.cs | 244 ++++++++++++------ .../GlobalSuppressions.cs | 7 +- .../THNETII.WinApi.Headers.FileApi.csproj | 6 +- 3 files changed, 169 insertions(+), 88 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs b/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs index 6871afc8..f3543b86 100644 --- a/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.FileApi/FileApiFunctions.cs @@ -1,8 +1,7 @@ -using Microsoft.Win32.SafeHandles; using System; -using System.IO; using System.Runtime.InteropServices; +using THNETII.InteropServices.Memory; using THNETII.WinApi.Native.MinWinBase; using THNETII.WinApi.Native.MinWinDef; using THNETII.WinApi.Native.WinError; @@ -59,49 +58,102 @@ in FILETIME lpFileTime2 #endregion // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 56 #region CreateDirectoryA function - /// + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateDirectoryA( - [In] LPCSTR lpPathName, + [In] string lpPathName, [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes ); - /// + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] - public static bool CreateDirectoryA(LPCSTR lpPathName) => + public static bool CreateDirectoryA(string lpPathName) => CreateDirectoryA(lpPathName, IntPtr.Zero); - /// + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool CreateDirectoryA( - [In] LPCSTR lpPathName, + [In] string lpPathName, [In, Optional] IntPtr lpSecurityAttributes ); - /// + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool CreateDirectoryA( - [In, MarshalAs(UnmanagedType.LPStr)] string lpPathName, + [In] LPCSTR lpPathName, [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes ); - /// + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] - public static bool CreateDirectoryA(string lpPathName) => + public static bool CreateDirectoryA(LPCSTR lpPathName) => CreateDirectoryA(lpPathName, IntPtr.Zero); - /// + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryA) + ". Instead the types in the System.IO namespace should be used.")] [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool CreateDirectoryA( - [In, MarshalAs(UnmanagedType.LPStr)] string lpPathName, + [In] LPCSTR lpPathName, [In, Optional] IntPtr lpSecurityAttributes ); #endregion // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 64 #region CreateDirectoryW function + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CreateDirectoryW( + [In] string lpPathName, + [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes + ); + + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + public static bool CreateDirectoryW(string lpPathName) => + CreateDirectoryW(lpPathName, IntPtr.Zero); + + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool CreateDirectoryW( + [In] string lpPathName, + [In, Optional] IntPtr lpSecurityAttributes + ); + + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool CreateDirectoryW( + [In] LPCWSTR lpPathName, + [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes + ); + + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + public static bool CreateDirectoryW(LPCWSTR lpPathName) => + CreateDirectoryW(lpPathName, IntPtr.Zero); + + /// + [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool CreateDirectoryW( + [In] LPCWSTR lpPathName, + [In, Optional] IntPtr lpSecurityAttributes + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 72 + #region CreateDirectory function /// /// Creates a new directory. If the underlying file system supports security on files and directories, the function applies a specified security descriptor to the new directory. /// To specify a template directory, use the function. @@ -163,92 +215,120 @@ private static extern bool CreateDirectoryA( /// /// /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CreateDirectoryW( - [In] LPCWSTR lpPathName, - [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes - ); - /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - public static bool CreateDirectoryW(LPCWSTR lpPathName) => - CreateDirectoryW(lpPathName, IntPtr.Zero); - /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CreateDirectoryW( - [In] LPCWSTR lpPathName, - [In, Optional] IntPtr lpSecurityAttributes - ); - /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CreateDirectoryW( - [In, MarshalAs(UnmanagedType.LPWStr)] string lpPathName, - [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes - ); - /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - public static bool CreateDirectoryW(string lpPathName) => - CreateDirectoryW(lpPathName, IntPtr.Zero); - /// - [Obsolete(".NET Applications should not call " + nameof(CreateDirectoryW) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CreateDirectoryW( - [In, MarshalAs(UnmanagedType.LPWStr)] string lpPathName, - [In, Optional] IntPtr lpSecurityAttributes - ); - #endregion - // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 72 - #region CreateDirectory function - /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] +#if !NETSTANDARD1_3 + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CreateDirectory( - [In] LPCTSTR lpPathName, + public static extern +#else + public static +#endif // NETSTANDARD1_3 + bool CreateDirectory( + [In] string lpPathName, [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes - ); - /// + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CreateDirectoryA(lpPathName, lpSecurityAttributes), + 2 => CreateDirectoryW(lpPathName, lpSecurityAttributes), + _ => throw new PlatformNotSupportedException(), + }; +#endif // NETSTANDARD1_3 + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] public static bool CreateDirectory( - [In] LPCTSTR lpPathName - ) => - CreateDirectory(lpPathName, IntPtr.Zero); - /// + string lpPathName + ) => CreateDirectory(lpPathName, IntPtr.Zero); + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] - [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] +#if !NETSTANDARD1_3 + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CreateDirectory( - [In] LPCTSTR lpPathName, + private static extern +#else + private static +#endif // NETSTANDARD1_3 + bool CreateDirectory( + [In] string lpPathName, [In, Optional] IntPtr lpSecurityAttributes - ); + ) #if !NETSTANDARD1_3 - /// + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CreateDirectoryA(lpPathName, lpSecurityAttributes), + 2 => CreateDirectoryW(lpPathName, lpSecurityAttributes), + _ => throw new PlatformNotSupportedException(), + }; +#endif // NETSTANDARD1_3 + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] +#if !NETSTANDARD1_3 [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool CreateDirectory( - [In, MarshalAs(UnmanagedType.LPTStr)] string lpPathName, + public static extern +#else + public static +#endif // NETSTANDARD1_3 + bool CreateDirectory( + [In] LPCTSTR lpPathName, [In, Optional] in SECURITY_ATTRIBUTES lpSecurityAttributes - ); - /// + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CreateDirectoryA( + Pointer.Create(lpPathName.Pointer), + lpSecurityAttributes), + 2 => CreateDirectoryW( + Pointer.Create(lpPathName.Pointer), + lpSecurityAttributes), + _ => throw new PlatformNotSupportedException(), + }; +#endif // NETSTANDARD1_3 + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] - public static bool CreateDirectory(string lpPathName) => - CreateDirectory(lpPathName, IntPtr.Zero); - /// + public static bool CreateDirectory( + [In] LPCTSTR lpPathName + ) => CreateDirectory(lpPathName, IntPtr.Zero); + + /// [Obsolete(".NET Applications should not call " + nameof(CreateDirectory) + ". Instead the types in the System.IO namespace should be used.")] +#if !NETSTANDARD1_3 [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Auto)] [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CreateDirectory( - [In, MarshalAs(UnmanagedType.LPTStr)] string lpPathName, + private static extern +#else + private static +#endif // NETSTANDARD1_3 + bool CreateDirectory( + [In] LPCTSTR lpPathName, [In, Optional] IntPtr lpSecurityAttributes - ); -#endif // !NETSTANDARD1_3 + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CreateDirectoryA( + Pointer.Create(lpPathName.Pointer), + lpSecurityAttributes), + 2 => CreateDirectoryW( + Pointer.Create(lpPathName.Pointer), + lpSecurityAttributes), + _ => throw new PlatformNotSupportedException(), + }; +#endif // NETSTANDARD1_3 #endregion // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\fileapi.h, line 116 #region DefineDosDeviceW function diff --git a/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs index 24c1463b..ea973baf 100644 --- a/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.FileApi/GlobalSuppressions.cs @@ -1,11 +1,12 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. using System.Diagnostics.CodeAnalysis; -[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] -[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")] +[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous reference in cref attribute")] [assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments", Justification = "Erroneously reported as not specified")] +[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")] +[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] [assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")] diff --git a/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj b/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj index 9f091a2b..5622729d 100644 --- a/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj +++ b/src-native/THNETII.WinApi.Headers.FileApi/THNETII.WinApi.Headers.FileApi.csproj @@ -1,11 +1,11 @@ - + - 7.2 + 8 netstandard1.3;netstandard2.0 true - CS1591 + $(NoWarn);CS1591;CS0419 THNETII.WinApi.Native.FileApi From e227a5d730ab2a5043f87365ddb1cfef739b4651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 15:20:40 +0200 Subject: [PATCH 03/50] Clean up MinWinDef macros --- src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs b/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs index 134802c3..34bb2553 100644 --- a/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs +++ b/src-native/THNETII.WinApi.Headers.MinWinDef/MinWinDefMacros.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Text; using THNETII.InteropServices.Bitwise; namespace THNETII.WinApi.Native.MinWinDef From 9bfd62b54464fae7f49116fcfbf6ed093fabefd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:03:10 +0200 Subject: [PATCH 04/50] Remove documentation warnings from SysInfoApi --- .../COMPUTER_NAME_FORMAT.cs | 4 +++- .../GlobalSuppressions.cs | 3 ++- .../MEMORYSTATUSEX.cs | 6 ++++-- .../THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs | 4 +++- .../SysInfoApiFunctions.cs | 7 ++++++- .../THNETII.WinApi.Headers.SysInfoApi.csproj | 10 ++++++++-- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs index 9867c3a6..bf4cc4ae 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/COMPUTER_NAME_FORMAT.cs @@ -1,5 +1,7 @@ -namespace THNETII.WinApi.Native.SysInfoApi +namespace THNETII.WinApi.Native.SysInfoApi { + using static SysInfoApiFunctions; + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 296 /// /// Specifies a type of computer name. diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs index 3295f902..decb72d3 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/GlobalSuppressions.cs @@ -1,4 +1,4 @@ -// This file is used by Code Analysis to maintain SuppressMessage +// This file is used by Code Analysis to maintain SuppressMessage // attributes that are applied to this project. // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. @@ -13,3 +13,4 @@ [assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")] [assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments")] [assembly: SuppressMessage("Documentation", "CA1200: Avoid using cref tags with a prefix")] +[assembly: SuppressMessage("Documentation", "CS0419: Ambiguous cref reference")] diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs index c3882fa8..cae246dd 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/MEMORYSTATUSEX.cs @@ -1,10 +1,12 @@ -using System.ComponentModel; +using System.ComponentModel; using System.Runtime.InteropServices; using THNETII.InteropServices.Memory; namespace THNETII.WinApi.Native.SysInfoApi { + using static SysInfoApiFunctions; + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 72 /// /// Contains information about the current state of both physical and virtual memory, including extended memory. The function stores information in this structure. @@ -48,7 +50,7 @@ public double MemoryLoadPercentage /// public ulong ullTotalPageFile; /// - /// The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than the system-wide available commit value. To calculate the system-wide available commit value, call and subtract the value of from the value of . + /// The maximum amount of memory the current process can commit, in bytes. This value is equal to or smaller than the system-wide available commit value. To calculate the system-wide available commit value, call and subtract the value of from the value of . /// public ulong ullAvailPageFile; /// diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs index a884f8f1..42d4b93b 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/SYSTEM_INFO.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Runtime.InteropServices; @@ -6,7 +6,9 @@ namespace THNETII.WinApi.Native.SysInfoApi { + using static LOGICAL_PROCESSOR_RELATIONSHIP; using static PROCESSOR_ARCHITECTURE; + using static SysInfoApiFunctions; // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\sysinfoapi.h, line 47 /// diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs b/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs index c91b3ba7..7f1e3ae3 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/SysInfoApiFunctions.cs @@ -1,11 +1,15 @@ -using Microsoft.Win32.SafeHandles; +using Microsoft.Win32.SafeHandles; + using System; using System.Runtime.InteropServices; using System.Text; + using THNETII.InteropServices.Memory; using THNETII.WinApi.Native.MinWinBase; using THNETII.WinApi.Native.WinError; using THNETII.WinApi.Native.WinNT; +using THNETII.WinApi.Native.ErrHandlingApi; +using THNETII.WinApi.Native.WinUser; #if NETSTANDARD1_6 using EntryPointNotFoundException = System.Exception; @@ -14,6 +18,7 @@ namespace THNETII.WinApi.Native.SysInfoApi { using static COMPUTER_NAME_FORMAT; + using static ErrHandlingApiFunctions; using static LOGICAL_PROCESSOR_RELATIONSHIP; using static NativeLibraryNames; using static WinErrorConstants; diff --git a/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj b/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj index 5e01a170..b3a60ed2 100644 --- a/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj +++ b/src-native/THNETII.WinApi.Headers.SysInfoApi/THNETII.WinApi.Headers.SysInfoApi.csproj @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ 7.3 netstandard1.6;netstandard2.0 true - CS1591 + $(NoWarn);CS0419;CS1591 THNETII.WinApi.Native.SysInfoApi @@ -28,6 +28,12 @@ All + + All + + + All + From 66a3190409720c70f75fb639b315673514a336b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:19:15 +0200 Subject: [PATCH 05/50] WinNls.h: Initial Commit From 13ff7ba82c01cf6995c140965ad1ebb37b466860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:29:04 +0200 Subject: [PATCH 06/50] Add WinNLS projects --- TH-NETII Windows API.sln | 30 +++++++++++++++++++ .../THNETII.WinApi.Sample.Native/main.c | 8 ++--- .../THNETII.WinApi.Constants.WinNls.csproj | 16 ++++++++++ .../WinNlsConstants.cs | 15 ++++++++++ .../THNETII.WinApi.Headers.WinNls.csproj | 18 +++++++++++ 5 files changed, 83 insertions(+), 4 deletions(-) create mode 100644 src-native/THNETII.WinApi.Constants.WinNls/THNETII.WinApi.Constants.WinNls.csproj create mode 100644 src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj diff --git a/TH-NETII Windows API.sln b/TH-NETII Windows API.sln index 71e775d5..e7d55f97 100644 --- a/TH-NETII Windows API.sln +++ b/TH-NETII Windows API.sln @@ -99,6 +99,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.AccC EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{20AA662D-26E7-4284-BCAA-02767F66C2F0}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Headers.WinNls", "src-native\THNETII.WinApi.Headers.WinNls\THNETII.WinApi.Headers.WinNls.csproj", "{E567A746-854C-434A-9E30-39AD10F39E06}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "THNETII.WinApi.Constants.WinNls", "src-native\THNETII.WinApi.Constants.WinNls\THNETII.WinApi.Constants.WinNls.csproj", "{D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -517,6 +521,30 @@ Global {8FA68C49-D060-4DE2-94A3-996320B314E2}.Release|x64.Build.0 = Release|Any CPU {8FA68C49-D060-4DE2-94A3-996320B314E2}.Release|x86.ActiveCfg = Release|Any CPU {8FA68C49-D060-4DE2-94A3-996320B314E2}.Release|x86.Build.0 = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|x64.ActiveCfg = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|x64.Build.0 = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|x86.ActiveCfg = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Debug|x86.Build.0 = Debug|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|Any CPU.Build.0 = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|x64.ActiveCfg = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|x64.Build.0 = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|x86.ActiveCfg = Release|Any CPU + {E567A746-854C-434A-9E30-39AD10F39E06}.Release|x86.Build.0 = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|x64.ActiveCfg = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|x64.Build.0 = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|x86.ActiveCfg = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Debug|x86.Build.0 = Debug|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|Any CPU.Build.0 = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|x64.ActiveCfg = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|x64.Build.0 = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|x86.ActiveCfg = Release|Any CPU + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -557,6 +585,8 @@ Global {E4A4DA91-3696-40A6-9834-E5FAACEF682E} = {9689DB3E-1ED7-478C-AC14-C734B0397619} {C0B32983-2879-4DAD-B834-8A40570A35CA} = {9689DB3E-1ED7-478C-AC14-C734B0397619} {8FA68C49-D060-4DE2-94A3-996320B314E2} = {9689DB3E-1ED7-478C-AC14-C734B0397619} + {E567A746-854C-434A-9E30-39AD10F39E06} = {9689DB3E-1ED7-478C-AC14-C734B0397619} + {D6A0D437-AB43-4F6E-8064-6C41CD24F6F7} = {9689DB3E-1ED7-478C-AC14-C734B0397619} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6EF7C9CF-E403-4B60-AB44-5F9FFEB668B7} diff --git a/src-native-c/THNETII.WinApi.Sample.Native/main.c b/src-native-c/THNETII.WinApi.Sample.Native/main.c index d00df0ce..3897b7be 100644 --- a/src-native-c/THNETII.WinApi.Sample.Native/main.c +++ b/src-native-c/THNETII.WinApi.Sample.Native/main.c @@ -1,12 +1,12 @@ -#include +#include int main(int argc, char* argv[]) { - ACE_HEADER instance; + DWORD instance; const int size = sizeof(instance); - const int value = ACE_OBJECT_TYPE_PRESENT; + const int value = NULL; - const void* ptr = AccFree; + const void* ptr = ConvertDefaultLocale; return EXIT_SUCCESS; } diff --git a/src-native/THNETII.WinApi.Constants.WinNls/THNETII.WinApi.Constants.WinNls.csproj b/src-native/THNETII.WinApi.Constants.WinNls/THNETII.WinApi.Constants.WinNls.csproj new file mode 100644 index 00000000..c90899d7 --- /dev/null +++ b/src-native/THNETII.WinApi.Constants.WinNls/THNETII.WinApi.Constants.WinNls.csproj @@ -0,0 +1,16 @@ + + + + + 8 + netstandard1.0;netstandard2.0 + true + CS1591 + THNETII.WinApi.Native.WinNls + + + + + + + diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs new file mode 100644 index 00000000..3a865977 --- /dev/null +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -0,0 +1,15 @@ +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h + //////////////////////////////////////////////////////////////////////////// + // + // Constants + // + // Define all constants for the NLS component here. + // + //////////////////////////////////////////////////////////////////////////// + + public static class WinNlsConstants + { + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj new file mode 100644 index 00000000..88bb3e2f --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj @@ -0,0 +1,18 @@ + + + + + 8 + netstandard1.0;netstandard2.0 + true + $(NoWarn);CS1591;CS0419 + THNETII.WinApi.Native.WinNls + + + + + All + + + + From 4b013c8aae294ae603b78a2c649af1acbd7d2e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:32:43 +0200 Subject: [PATCH 07/50] Add WinNLS constants, winnls.h line 102 --- .../THNETII.WinApi.Constants.WinNls/GlobalSuppressions.cs | 8 ++++++++ .../THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 src-native/THNETII.WinApi.Constants.WinNls/GlobalSuppressions.cs diff --git a/src-native/THNETII.WinApi.Constants.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Constants.WinNls/GlobalSuppressions.cs new file mode 100644 index 00000000..fa505ab1 --- /dev/null +++ b/src-native/THNETII.WinApi.Constants.WinNls/GlobalSuppressions.cs @@ -0,0 +1,8 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 3a865977..01865c02 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -11,5 +11,11 @@ namespace THNETII.WinApi.Native.WinNls public static class WinNlsConstants { + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 98 + // + // String Length Maximums. + // + public const int MAX_LEADBYTES = 12; // 5 ranges, 2 bytes ea., 0 term. + public const int MAX_DEFAULTCHAR = 2; // single or double byte } } From 1be5ff71b3cc9138f1e1ceedb41196a10e9de44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:35:00 +0200 Subject: [PATCH 08/50] Add Surrogate range constants, winnls.h line 134 --- .../WinNlsConstants.cs | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 01865c02..5538acc9 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -17,5 +17,39 @@ public static class WinNlsConstants // public const int MAX_LEADBYTES = 12; // 5 ranges, 2 bytes ea., 0 term. public const int MAX_DEFAULTCHAR = 2; // single or double byte + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 104 + // + // Surrogate pairs + // + // Conversion examples: + // + // A) The first character in the Surrogate range (D800, DC00) as UTF-32: + // + // 1. D800: binary 1101100000000000 (lower ten bits: 0000000000) + // 2. DC00: binary 1101110000000000 (lower ten bits: 0000000000) + // 3. Concatenate 0000000000+0000000000 = 0x0000 + // 4. Add 0x10000 + // + // Result: U+10000. This is correct, since the first character in the Supplementary character + // range immediately follows the last code point in the 16-bit UTF-16 range (U+FFFF) + // + // B) A UTF-32 code point such as U+2040A (this a CJK character in CJK Extension B), and wish + // to convert it in UTF-16: + // + // 1. Subtract 0x10000 - Result: 0x1040A + // 2. Split into two ten-bit pieces: 0001000001 0000001010 + // 3. Add 1101100000000000 (0xD800) to the high 10 bits piece (0001000001) - Result: 1101100001000001 (0xD841) + // 4. Add 1101110000000000 (0xDC00) to the low 10 bits piece (0000001010) - Result: 1101110000001010 (0xDC0A) + // + // RESULT: The surrogate pair: U+D841, U+DC0A + // + // Special Unicode code point values, for use with UTF-16 surrogate pairs. + // + public const short HIGH_SURROGATE_START = unchecked((short)0xd800); + public const short HIGH_SURROGATE_END = unchecked((short)0xdbff); + public const short LOW_SURROGATE_START = unchecked((short)0xdc00); + public const short LOW_SURROGATE_END = unchecked((short)0xdfff); + } } From 1399fe282b4a41b4c4221a288789eb689200e294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 16:39:45 +0200 Subject: [PATCH 09/50] MBCS and Unicode Translation Flag constants, winnls.h line 164 --- .../WinNlsConstants.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 5538acc9..733212b0 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -1,3 +1,5 @@ +using System; + namespace THNETII.WinApi.Native.WinNls { // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h @@ -51,5 +53,32 @@ public static class WinNlsConstants public const short LOW_SURROGATE_START = unchecked((short)0xdc00); public const short LOW_SURROGATE_END = unchecked((short)0xdfff); + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 137 + // + // MBCS and Unicode Translation Flags. + // Please use Unicode, either UTF-16 (WCHAR) or UTF-8 (CP_UTF8) + // + // MB_PRECOMPOSED and MB_COMPOSITE are deprecated, not recommended, and + // provide out-of-date behavior. + // Windows typically uses Unicode Normalization Form C type sequences, + // If explicit normalization forms are required, please use NormalizeString. + [Obsolete("DEPRECATED: use single precomposed characters when possible.")] + public const int MB_PRECOMPOSED = 0x00000001; // DEPRECATED: use single precomposed characters when possible. + [Obsolete("DEPRECATED: use multiple discrete characters when possible.")] + public const int MB_COMPOSITE = 0x00000002; // DEPRECATED: use multiple discrete characters when possible. + [Obsolete("DEPRECATED: use glyph chars, not ctrl chars")] + public const int MB_USEGLYPHCHARS = 0x00000004; // DEPRECATED: use glyph chars, not ctrl chars + public const int MB_ERR_INVALID_CHARS = 0x00000008; // error for invalid chars + + // WC_COMPOSITECHECK, WC_DISCARDNS and WC_SEPCHARS are deprecated, not recommended, + // and provide out-of-date behavior. + // Windows typically uses Unicode Normalization Form C type sequences, + // If explicit normalization forms are required, please use NormalizeString. + public const int WC_COMPOSITECHECK = 0x00000200; // convert composite to precomposed + public const int WC_DISCARDNS = 0x00000010; // discard non-spacing chars // Used with WC_COMPOSITECHECK + public const int WC_SEPCHARS = 0x00000020; // generate separate chars // Used with WC_COMPOSITECHECK + public const int WC_DEFAULTCHAR = 0x00000040; // replace w/ default char // Used with WC_COMPOSITECHECK + public const int WC_ERR_INVALID_CHARS = 0x00000080; // error for invalid chars + public const int WC_NO_BEST_FIT_CHARS = 0x00000400; // do not use best fit chars } } From 15a1dc4ac41642ffd095927bd70eb8279371bc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 17:24:20 +0200 Subject: [PATCH 10/50] Additional Win NLS constants, winnls.h line 1032 --- .../WinNlsConstants.cs | 1338 ++++++++++++++++- 1 file changed, 1329 insertions(+), 9 deletions(-) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 733212b0..98707ac6 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -63,22 +63,1342 @@ public static class WinNlsConstants // Windows typically uses Unicode Normalization Form C type sequences, // If explicit normalization forms are required, please use NormalizeString. [Obsolete("DEPRECATED: use single precomposed characters when possible.")] - public const int MB_PRECOMPOSED = 0x00000001; // DEPRECATED: use single precomposed characters when possible. + public const int MB_PRECOMPOSED = 0x00000001; [Obsolete("DEPRECATED: use multiple discrete characters when possible.")] - public const int MB_COMPOSITE = 0x00000002; // DEPRECATED: use multiple discrete characters when possible. + public const int MB_COMPOSITE = 0x00000002; [Obsolete("DEPRECATED: use glyph chars, not ctrl chars")] - public const int MB_USEGLYPHCHARS = 0x00000004; // DEPRECATED: use glyph chars, not ctrl chars + public const int MB_USEGLYPHCHARS = 0x00000004; public const int MB_ERR_INVALID_CHARS = 0x00000008; // error for invalid chars // WC_COMPOSITECHECK, WC_DISCARDNS and WC_SEPCHARS are deprecated, not recommended, // and provide out-of-date behavior. // Windows typically uses Unicode Normalization Form C type sequences, // If explicit normalization forms are required, please use NormalizeString. - public const int WC_COMPOSITECHECK = 0x00000200; // convert composite to precomposed - public const int WC_DISCARDNS = 0x00000010; // discard non-spacing chars // Used with WC_COMPOSITECHECK - public const int WC_SEPCHARS = 0x00000020; // generate separate chars // Used with WC_COMPOSITECHECK - public const int WC_DEFAULTCHAR = 0x00000040; // replace w/ default char // Used with WC_COMPOSITECHECK - public const int WC_ERR_INVALID_CHARS = 0x00000080; // error for invalid chars - public const int WC_NO_BEST_FIT_CHARS = 0x00000400; // do not use best fit chars + /// convert composite to precomposed + public const int WC_COMPOSITECHECK = 0x00000200; + /// + /// discard non-spacing chars + /// Used with + /// + public const int WC_DISCARDNS = 0x00000010; + /// + /// generate separate chars + /// Used with + /// + public const int WC_SEPCHARS = 0x00000020; + /// + /// replace w/ default char + /// Used with + /// + public const int WC_DEFAULTCHAR = 0x00000040; + /// error for invalid chars + public const int WC_ERR_INVALID_CHARS = 0x00000080; + /// do not use best fit chars + public const int WC_NO_BEST_FIT_CHARS = 0x00000400; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 167 + // + // Character Type Flags. + // + /// ctype 1 information + public const int CT_CTYPE1 = 0x00000001; + /// ctype 2 information + public const int CT_CTYPE2 = 0x00000002; + /// ctype 3 information + public const int CT_CTYPE3 = 0x00000004; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 174 + // + // CType 1 Flag Bits. + // + /// upper case + public const short C1_UPPER = 0x0001; + /// lower case + public const short C1_LOWER = 0x0002; + /// decimal digits + public const short C1_DIGIT = 0x0004; + /// spacing characters + public const short C1_SPACE = 0x0008; + /// punctuation characters + public const short C1_PUNCT = 0x0010; + /// control characters + public const short C1_CNTRL = 0x0020; + /// blank characters + public const short C1_BLANK = 0x0040; + /// other digits + public const short C1_XDIGIT = 0x0080; + /// any linguistic character + public const short C1_ALPHA = 0x0100; + /// defined character + public const short C1_DEFINED = 0x0200; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 188 + // + // CType 2 Flag Bits. + // + /// left to right + public const short C2_LEFTTORIGHT = 0x0001; + /// right to left + public const short C2_RIGHTTOLEFT = 0x0002; + + /// European number, digit + public const short C2_EUROPENUMBER = 0x0003; + /// European numeric separator + public const short C2_EUROPESEPARATOR = 0x0004; + /// European numeric terminator + public const short C2_EUROPETERMINATOR = 0x0005; + /// Arabic number + public const short C2_ARABICNUMBER = 0x0006; + /// common numeric separator + public const short C2_COMMONSEPARATOR = 0x0007; + + /// block separator + public const short C2_BLOCKSEPARATOR = 0x0008; + /// segment separator + public const short C2_SEGMENTSEPARATOR = 0x0009; + /// white space + public const short C2_WHITESPACE = 0x000A; + /// other neutrals + public const short C2_OTHERNEUTRAL = 0x000B; + + /// no implicit directionality + public const short C2_NOTAPPLICABLE = 0x0000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 207 + // + // CType 3 Flag Bits. + // + /// nonspacing character + public const short C3_NONSPACING = 0x0001; + /// diacritic mark + public const short C3_DIACRITIC = 0x0002; + /// vowel mark + public const short C3_VOWELMARK = 0x0004; + /// symbols + public const short C3_SYMBOL = 0x0008; + + /// katakana character + public const short C3_KATAKANA = 0x0010; + /// hiragana character + public const short C3_HIRAGANA = 0x0020; + /// half width character + public const short C3_HALFWIDTH = 0x0040; + /// full width character + public const short C3_FULLWIDTH = 0x0080; + /// ideographic character + public const short C3_IDEOGRAPH = 0x0100; + /// Arabic kashida character + public const short C3_KASHIDA = 0x0200; + /// lexical character + public const short C3_LEXICAL = 0x0400; + /// high surrogate code unit + public const short C3_HIGHSURROGATE = 0x0800; + /// low surrogate code unit + public const short C3_LOWSURROGATE = 0x1000; + + /// any linguistic char (C1_ALPHA) + public const short C3_ALPHA = unchecked((short)0x8000); + + /// ctype 3 is not applicable + public const short C3_NOTAPPLICABLE = 0x0000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 230 + // + // String Flags. + // + /// ignore case + public const int NORM_IGNORECASE = 0x00000001; + /// ignore nonspacing chars + public const int NORM_IGNORENONSPACE = 0x00000002; + /// ignore symbols + public const int NORM_IGNORESYMBOLS = 0x00000004; + + /// linguistically appropriate 'ignore case' + public const int LINGUISTIC_IGNORECASE = 0x00000010; + /// linguistically appropriate 'ignore nonspace' + public const int LINGUISTIC_IGNOREDIACRITIC = 0x00000020; + + /// ignore kanatype + public const int NORM_IGNOREKANATYPE = 0x00010000; + /// ignore width + public const int NORM_IGNOREWIDTH = 0x00020000; + /// use linguistic rules for casing + public const int NORM_LINGUISTIC_CASING = 0x08000000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 245 + // + // Locale Independent Mapping Flags. + // + /// fold compatibility zone chars + public const int MAP_FOLDCZONE = 0x00000010; + /// convert to precomposed chars + public const int MAP_PRECOMPOSED = 0x00000020; + /// convert to composite chars + public const int MAP_COMPOSITE = 0x00000040; + /// all digits to ASCII 0-9 + public const int MAP_FOLDDIGITS = 0x00000080; + + /// expand all ligatures + public const int MAP_EXPAND_LIGATURES = 0x00002000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 257 + // + // Locale Dependent Mapping Flags. + // + /// lower case letters + public const int LCMAP_LOWERCASE = 0x00000100; + /// UPPER CASE LETTERS + public const int LCMAP_UPPERCASE = 0x00000200; + /// Title Case Letters + public const int LCMAP_TITLECASE = 0x00000300; + + /// WC sort key (normalize) + public const int LCMAP_SORTKEY = 0x00000400; + /// byte reversal + public const int LCMAP_BYTEREV = 0x00000800; + + /// map katakana to hiragana + public const int LCMAP_HIRAGANA = 0x00100000; + /// map hiragana to katakana + public const int LCMAP_KATAKANA = 0x00200000; + /// map double byte to single byte + public const int LCMAP_HALFWIDTH = 0x00400000; + /// map single byte to double byte + public const int LCMAP_FULLWIDTH = 0x00800000; + + /// use linguistic rules for casing + public const int LCMAP_LINGUISTIC_CASING = 0x01000000; + + /// map traditional chinese to simplified chinese + public const int LCMAP_SIMPLIFIED_CHINESE = 0x02000000; + /// map simplified chinese to traditional chinese + public const int LCMAP_TRADITIONAL_CHINESE = 0x04000000; + + public const int LCMAP_SORTHANDLE = 0x20000000; + public const int LCMAP_HASH = 0x00040000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 285 + // + // Search Flags + // + /// see if value is at the beginning of source + public const int FIND_STARTSWITH = 0x00100000; + /// see if value is at the end of source + public const int FIND_ENDSWITH = 0x00200000; + /// look for value in source, starting at the beginning + public const int FIND_FROMSTART = 0x00400000; + /// look for value in source, starting at the end + public const int FIND_FROMEND = 0x00800000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 294 + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + // Language Group Enumeration Flags. + // + // The "Language Group" concept is an obsolete concept. + // The groups returned are not well defined, arbitrary, inconsistent, inaccurate, + // no longer maintained, and no longer supported. + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + /// installed language group ids + public const int LGRPID_INSTALLED = 0x00000001; + /// supported language group ids + public const int LGRPID_SUPPORTED = 0x00000002; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 309 + // + // Locale Enumeration Flags. + // + /// installed locale ids + public const int LCID_INSTALLED = 0x00000001; + /// supported locale ids + public const int LCID_SUPPORTED = 0x00000002; + /// alternate sort locale ids + public const int LCID_ALTERNATE_SORTS = 0x00000004; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 317 + // + // Named based enumeration flags. + // + /// enumerate all named based locales + public const int LOCALE_ALL = 0; + /// shipped locales and/or replacements for them + public const int LOCALE_WINDOWS = 0x00000001; + /// supplemental locales only + public const int LOCALE_SUPPLEMENTAL = 0x00000002; + /// alternate sort locales + public const int LOCALE_ALTERNATE_SORTS = 0x00000004; + /// locales that replace shipped locales (callback flag only) + public const int LOCALE_REPLACEMENT = 0x00000008; + /// Locales that are "neutral" (language only, region data is default) + public const int LOCALE_NEUTRALDATA = 0x00000010; + /// Locales that contain language and region data + public const int LOCALE_SPECIFICDATA = 0x00000020; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 333 + // + // Code Page Enumeration Flags. + // + /// installed code page ids + public const int CP_INSTALLED = 0x00000001; + /// supported code page ids + public const int CP_SUPPORTED = 0x00000002; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 340 + // + // Sorting Flags. + // + // WORD Sort: culturally correct sort + // hyphen and apostrophe are special cased + // example: "coop" and "co-op" will sort together in a list + // + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // co-op <------- hyphen (punctuation) + // cork + // went + // were + // we're <------- apostrophe (punctuation) + // + // + // STRING Sort: hyphen and apostrophe will sort with all other symbols + // + // co-op <------- hyphen (punctuation) + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // cork + // we're <------- apostrophe (punctuation) + // went + // were + // + /// use string sort method + public const int SORT_STRINGSORT = 0x00001000; + + // Sort digits as numbers (ie: 2 comes before 10) + /// use digits as numbers sort method + public const int SORT_DIGITSASNUMBERS = 0x00000008; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 378 + // + // Compare String Return Values. + // + /// string 1 less than string 2 + public const int CSTR_LESS_THAN = 1; + /// string 1 equal to string 2 + public const int CSTR_EQUAL = 2; + /// string 1 greater than string 2 + public const int CSTR_GREATER_THAN = 3; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 386 + // + // Code Page Default Values. + // Please Use Unicode, either UTF-16 (as in WCHAR) or UTF-8 (code page CP_ACP) + // + /// default to ANSI code page + public const int CP_ACP = 0; + /// default to OEM code page + public const int CP_OEMCP = 1; + /// default to MAC code page + public const int CP_MACCP = 2; + /// current thread's ANSI code page + public const int CP_THREAD_ACP = 3; + /// SYMBOL translations + public const int CP_SYMBOL = 42; + + /// UTF-7 translation + public const int CP_UTF7 = 65000; + /// UTF-8 translation + public const int CP_UTF8 = 65001; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 399 + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + // Country/Region Codes. + // + // DEPRECATED: The GEOID concept is deprecated, please use + // Country/Region Names instead, eg: "US" instead of a GEOID like 244. + // See the documentation for GetGeoInfoEx. + // + // WARNING: These values are arbitrarily assigned values, please use + // standard country/region names instead, such as "US". + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + public const int CTRY_DEFAULT = 0; + + /// Albania + public const int CTRY_ALBANIA = 355; + /// Algeria + public const int CTRY_ALGERIA = 213; + /// Argentina + public const int CTRY_ARGENTINA = 54; + /// Armenia + public const int CTRY_ARMENIA = 374; + /// Australia + public const int CTRY_AUSTRALIA = 61; + /// Austria + public const int CTRY_AUSTRIA = 43; + /// Azerbaijan + public const int CTRY_AZERBAIJAN = 994; + /// Bahrain + public const int CTRY_BAHRAIN = 973; + /// Belarus + public const int CTRY_BELARUS = 375; + /// Belgium + public const int CTRY_BELGIUM = 32; + /// Belize + public const int CTRY_BELIZE = 501; + /// Bolivia + public const int CTRY_BOLIVIA = 591; + /// Brazil + public const int CTRY_BRAZIL = 55; + /// Brunei Darussalam + public const int CTRY_BRUNEI_DARUSSALAM = 673; + /// Bulgaria + public const int CTRY_BULGARIA = 359; + /// Canada + public const int CTRY_CANADA = 2; + /// Caribbean + public const int CTRY_CARIBBEAN = 1; + /// Chile + public const int CTRY_CHILE = 56; + /// Colombia + public const int CTRY_COLOMBIA = 57; + /// Costa Rica + public const int CTRY_COSTA_RICA = 506; + /// Croatia + public const int CTRY_CROATIA = 385; + /// Czech Republic + public const int CTRY_CZECH = 420; + /// Denmark + public const int CTRY_DENMARK = 45; + /// Dominican Republic + public const int CTRY_DOMINICAN_REPUBLIC = 1; + /// Ecuador + public const int CTRY_ECUADOR = 593; + /// Egypt + public const int CTRY_EGYPT = 20; + /// El Salvador + public const int CTRY_EL_SALVADOR = 503; + /// Estonia + public const int CTRY_ESTONIA = 372; + /// Faeroe Islands + public const int CTRY_FAEROE_ISLANDS = 298; + /// Finland + public const int CTRY_FINLAND = 358; + /// France + public const int CTRY_FRANCE = 33; + /// Georgia + public const int CTRY_GEORGIA = 995; + /// Germany + public const int CTRY_GERMANY = 49; + /// Greece + public const int CTRY_GREECE = 30; + /// Guatemala + public const int CTRY_GUATEMALA = 502; + /// Honduras + public const int CTRY_HONDURAS = 504; + /// Hong Kong S.A.R., P.R.C. + public const int CTRY_HONG_KONG = 852; + /// Hungary + public const int CTRY_HUNGARY = 36; + /// Iceland + public const int CTRY_ICELAND = 354; + /// India + public const int CTRY_INDIA = 91; + /// Indonesia + public const int CTRY_INDONESIA = 62; + /// Iran + public const int CTRY_IRAN = 981; + /// Iraq + public const int CTRY_IRAQ = 964; + /// Ireland + public const int CTRY_IRELAND = 353; + /// Israel + public const int CTRY_ISRAEL = 972; + /// Italy + public const int CTRY_ITALY = 39; + /// Jamaica + public const int CTRY_JAMAICA = 1; + /// Japan + public const int CTRY_JAPAN = 81; + /// Jordan + public const int CTRY_JORDAN = 962; + /// Kazakstan + public const int CTRY_KAZAKSTAN = 7; + /// Kenya + public const int CTRY_KENYA = 254; + /// Kuwait + public const int CTRY_KUWAIT = 965; + /// Kyrgyzstan + public const int CTRY_KYRGYZSTAN = 996; + /// Latvia + public const int CTRY_LATVIA = 371; + /// Lebanon + public const int CTRY_LEBANON = 961; + /// Libya + public const int CTRY_LIBYA = 218; + /// Liechtenstein + public const int CTRY_LIECHTENSTEIN = 41; + /// Lithuania + public const int CTRY_LITHUANIA = 370; + /// Luxembourg + public const int CTRY_LUXEMBOURG = 352; + /// Macao SAR, PRC + public const int CTRY_MACAU = 853; + /// Former Yugoslav Republic of Macedonia + public const int CTRY_MACEDONIA = 389; + /// Malaysia + public const int CTRY_MALAYSIA = 60; + /// Maldives + public const int CTRY_MALDIVES = 960; + /// Mexico + public const int CTRY_MEXICO = 52; + /// Principality of Monaco + public const int CTRY_MONACO = 33; + /// Mongolia + public const int CTRY_MONGOLIA = 976; + /// Morocco + public const int CTRY_MOROCCO = 212; + /// Netherlands + public const int CTRY_NETHERLANDS = 31; + /// New Zealand + public const int CTRY_NEW_ZEALAND = 64; + /// Nicaragua + public const int CTRY_NICARAGUA = 505; + /// Norway + public const int CTRY_NORWAY = 47; + /// Oman + public const int CTRY_OMAN = 968; + /// Islamic Republic of Pakistan + public const int CTRY_PAKISTAN = 92; + /// Panama + public const int CTRY_PANAMA = 507; + /// Paraguay + public const int CTRY_PARAGUAY = 595; + /// Peru + public const int CTRY_PERU = 51; + /// Republic of the Philippines + public const int CTRY_PHILIPPINES = 63; + /// Poland + public const int CTRY_POLAND = 48; + /// Portugal + public const int CTRY_PORTUGAL = 351; + /// People's Republic of China + public const int CTRY_PRCHINA = 86; + /// Puerto Rico + public const int CTRY_PUERTO_RICO = 1; + /// Qatar + public const int CTRY_QATAR = 974; + /// Romania + public const int CTRY_ROMANIA = 40; + /// Russia + public const int CTRY_RUSSIA = 7; + /// Saudi Arabia + public const int CTRY_SAUDI_ARABIA = 966; + /// Serbia + public const int CTRY_SERBIA = 381; + /// Singapore + public const int CTRY_SINGAPORE = 65; + /// Slovak Republic + public const int CTRY_SLOVAK = 421; + /// Slovenia + public const int CTRY_SLOVENIA = 386; + /// South Africa + public const int CTRY_SOUTH_AFRICA = 27; + /// Korea + public const int CTRY_SOUTH_KOREA = 82; + /// Spain + public const int CTRY_SPAIN = 34; + /// Sweden + public const int CTRY_SWEDEN = 46; + /// Switzerland + public const int CTRY_SWITZERLAND = 41; + /// Syria + public const int CTRY_SYRIA = 963; + /// Taiwan + public const int CTRY_TAIWAN = 886; + /// Tatarstan + public const int CTRY_TATARSTAN = 7; + /// Thailand + public const int CTRY_THAILAND = 66; + /// Trinidad y Tobago + public const int CTRY_TRINIDAD_Y_TOBAGO = 1; + /// Tunisia + public const int CTRY_TUNISIA = 216; + /// Turkey + public const int CTRY_TURKEY = 90; + /// U.A.E. + public const int CTRY_UAE = 971; + /// Ukraine + public const int CTRY_UKRAINE = 380; + /// United Kingdom + public const int CTRY_UNITED_KINGDOM = 44; + /// United States + public const int CTRY_UNITED_STATES = 1; + /// Uruguay + public const int CTRY_URUGUAY = 598; + /// Uzbekistan + public const int CTRY_UZBEKISTAN = 7; + /// Venezuela + public const int CTRY_VENEZUELA = 58; + /// Viet Nam + public const int CTRY_VIET_NAM = 84; + /// Yemen + public const int CTRY_YEMEN = 967; + /// Zimbabwe + public const int CTRY_ZIMBABWE = 263; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 528 + // + // Locale Types. + // + // These types are used for the GetLocaleInfo NLS API routine. + // Some of these types are also used for the SetLocaleInfo NLS API routine. + // + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 535 + // + // The following LCTypes may be used in combination with any other LCTypes. + // + // LOCALE_NOUSEROVERRIDE is also used in GetTimeFormat and + // GetDateFormat. + // + // LOCALE_RETURN_NUMBER will return the result from GetLocaleInfo as a + // number instead of a string. This flag is only valid for the LCTypes + // beginning with LOCALE_I. + // + // DEPRECATED: LOCALE_USE_CP_ACP is used in many of the A (Ansi) apis that need + // to do string translation. Callers are encouraged to use the W + // (WCHAR/Unicode) apis instead. + // + /// Not Recommended - do not use user overrides + public const int LOCALE_NOUSEROVERRIDE = unchecked((int)0x80000000); + [Obsolete("DEPRECATED, call Unicode APIs instead: use the system ACP")] + public const int LOCALE_USE_CP_ACP = 0x40000000; + + /// return number instead of string + public const int LOCALE_RETURN_NUMBER = 0x20000000; + + /// Flag to return the Genitive forms of month names + public const int LOCALE_RETURN_GENITIVE_NAMES = 0x10000000; + /// Flag to allow returning neutral names/lcids for name conversion + public const int LOCALE_ALLOW_NEUTRAL_NAMES = 0x08000000; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 562 + // + // The following LCTypes are mutually exclusive in that they may NOT + // be used in combination with each other. + // + + // + // These are the various forms of the name of the locale: + // + /// localized name of locale, eg "German (Germany)" in UI language + public const int LOCALE_SLOCALIZEDDISPLAYNAME = 0x00000002; + /// Display name (language + country/region usually) in English, eg "German (Germany)" + public const int LOCALE_SENGLISHDISPLAYNAME = 0x00000072; + /// Display name in native locale language, eg "Deutsch (Deutschland) + public const int LOCALE_SNATIVEDISPLAYNAME = 0x00000073; + + /// Language Display Name for a language, eg "German" in UI language + public const int LOCALE_SLOCALIZEDLANGUAGENAME = 0x0000006f; + /// English name of language, eg "German" + public const int LOCALE_SENGLISHLANGUAGENAME = 0x00001001; + /// native name of language, eg "Deutsch" + public const int LOCALE_SNATIVELANGUAGENAME = 0x00000004; + + /// localized name of country/region, eg "Germany" in UI language + public const int LOCALE_SLOCALIZEDCOUNTRYNAME = 0x00000006; + /// English name of country/region, eg "Germany" + public const int LOCALE_SENGLISHCOUNTRYNAME = 0x00001002; + /// native name of country/region, eg "Deutschland" + public const int LOCALE_SNATIVECOUNTRYNAME = 0x00000008; + + // Additional LCTypes + /// country/region dialing code, example: en-US and en-CA return 1. + public const int LOCALE_IDIALINGCODE = 0x00000005; + + /// list item separator, eg "," for "1,2,3,4" + public const int LOCALE_SLIST = 0x0000000C; + /// 0 = metric, 1 = US measurement system + public const int LOCALE_IMEASURE = 0x0000000D; + + /// decimal separator, eg "." for 1,234.00 + public const int LOCALE_SDECIMAL = 0x0000000E; + /// thousand separator, eg "," for 1,234.00 + public const int LOCALE_STHOUSAND = 0x0000000F; + /// digit grouping, eg "3;0" for 1,000,000 + public const int LOCALE_SGROUPING = 0x00000010; + /// number of fractional digits eg 2 for 1.00 + public const int LOCALE_IDIGITS = 0x00000011; + /// leading zeros for decimal, 0 for .97, 1 for 0.97 + public const int LOCALE_ILZERO = 0x00000012; + /// negative number mode, 0-4, see documentation + public const int LOCALE_INEGNUMBER = 0x00001010; + /// native digits for 0-9, eg "0123456789" + public const int LOCALE_SNATIVEDIGITS = 0x00000013; + + /// local monetary symbol, eg "$" + public const int LOCALE_SCURRENCY = 0x00000014; + /// intl monetary symbol, eg "USD" + public const int LOCALE_SINTLSYMBOL = 0x00000015; + /// monetary decimal separator, eg "." for $1,234.00 + public const int LOCALE_SMONDECIMALSEP = 0x00000016; + /// monetary thousand separator, eg "," for $1,234.00 + public const int LOCALE_SMONTHOUSANDSEP = 0x00000017; + /// monetary grouping, eg "3;0" for $1,000,000.00 + public const int LOCALE_SMONGROUPING = 0x00000018; + /// # local monetary digits, eg 2 for $1.00 + public const int LOCALE_ICURRDIGITS = 0x00000019; + /// positive currency mode, 0-3, see documentation + public const int LOCALE_ICURRENCY = 0x0000001B; + /// negative currency mode, 0-15, see documentation + public const int LOCALE_INEGCURR = 0x0000001C; + + /// short date format string, eg "MM/dd/yyyy" + public const int LOCALE_SSHORTDATE = 0x0000001F; + /// long date format string, eg "dddd, MMMM dd, yyyy" + public const int LOCALE_SLONGDATE = 0x00000020; + /// time format string, eg "HH:mm:ss" + public const int LOCALE_STIMEFORMAT = 0x00001003; + /// AM designator, eg "AM" + public const int LOCALE_SAM = 0x00000028; + /// PM designator, eg "PM" + public const int LOCALE_SPM = 0x00000029; + + /// type of calendar specifier, eg CAL_GREGORIAN + public const int LOCALE_ICALENDARTYPE = 0x00001009; + /// additional calendar types specifier, eg CAL_GREGORIAN_US + public const int LOCALE_IOPTIONALCALENDAR = 0x0000100B; + /// first day of week specifier, 0-6, 0=Monday, 6=Sunday + public const int LOCALE_IFIRSTDAYOFWEEK = 0x0000100C; + /// first week of year specifier, 0-2, see documentation + public const int LOCALE_IFIRSTWEEKOFYEAR = 0x0000100D; + + /// long name for Monday + public const int LOCALE_SDAYNAME1 = 0x0000002A; + /// long name for Tuesday + public const int LOCALE_SDAYNAME2 = 0x0000002B; + /// long name for Wednesday + public const int LOCALE_SDAYNAME3 = 0x0000002C; + /// long name for Thursday + public const int LOCALE_SDAYNAME4 = 0x0000002D; + /// long name for Friday + public const int LOCALE_SDAYNAME5 = 0x0000002E; + /// long name for Saturday + public const int LOCALE_SDAYNAME6 = 0x0000002F; + /// long name for Sunday + public const int LOCALE_SDAYNAME7 = 0x00000030; + /// abbreviated name for Monday + public const int LOCALE_SABBREVDAYNAME1 = 0x00000031; + /// abbreviated name for Tuesday + public const int LOCALE_SABBREVDAYNAME2 = 0x00000032; + /// abbreviated name for Wednesday + public const int LOCALE_SABBREVDAYNAME3 = 0x00000033; + /// abbreviated name for Thursday + public const int LOCALE_SABBREVDAYNAME4 = 0x00000034; + /// abbreviated name for Friday + public const int LOCALE_SABBREVDAYNAME5 = 0x00000035; + /// abbreviated name for Saturday + public const int LOCALE_SABBREVDAYNAME6 = 0x00000036; + /// abbreviated name for Sunday + public const int LOCALE_SABBREVDAYNAME7 = 0x00000037; + /// long name for January + public const int LOCALE_SMONTHNAME1 = 0x00000038; + /// long name for February + public const int LOCALE_SMONTHNAME2 = 0x00000039; + /// long name for March + public const int LOCALE_SMONTHNAME3 = 0x0000003A; + /// long name for April + public const int LOCALE_SMONTHNAME4 = 0x0000003B; + /// long name for May + public const int LOCALE_SMONTHNAME5 = 0x0000003C; + /// long name for June + public const int LOCALE_SMONTHNAME6 = 0x0000003D; + /// long name for July + public const int LOCALE_SMONTHNAME7 = 0x0000003E; + /// long name for August + public const int LOCALE_SMONTHNAME8 = 0x0000003F; + /// long name for September + public const int LOCALE_SMONTHNAME9 = 0x00000040; + /// long name for October + public const int LOCALE_SMONTHNAME10 = 0x00000041; + /// long name for November + public const int LOCALE_SMONTHNAME11 = 0x00000042; + /// long name for December + public const int LOCALE_SMONTHNAME12 = 0x00000043; + /// long name for 13th month (if exists) + public const int LOCALE_SMONTHNAME13 = 0x0000100E; + /// abbreviated name for January + public const int LOCALE_SABBREVMONTHNAME1 = 0x00000044; + /// abbreviated name for February + public const int LOCALE_SABBREVMONTHNAME2 = 0x00000045; + /// abbreviated name for March + public const int LOCALE_SABBREVMONTHNAME3 = 0x00000046; + /// abbreviated name for April + public const int LOCALE_SABBREVMONTHNAME4 = 0x00000047; + /// abbreviated name for May + public const int LOCALE_SABBREVMONTHNAME5 = 0x00000048; + /// abbreviated name for June + public const int LOCALE_SABBREVMONTHNAME6 = 0x00000049; + /// abbreviated name for July + public const int LOCALE_SABBREVMONTHNAME7 = 0x0000004A; + /// abbreviated name for August + public const int LOCALE_SABBREVMONTHNAME8 = 0x0000004B; + /// abbreviated name for September + public const int LOCALE_SABBREVMONTHNAME9 = 0x0000004C; + /// abbreviated name for October + public const int LOCALE_SABBREVMONTHNAME10 = 0x0000004D; + /// abbreviated name for November + public const int LOCALE_SABBREVMONTHNAME11 = 0x0000004E; + /// abbreviated name for December + public const int LOCALE_SABBREVMONTHNAME12 = 0x0000004F; + /// abbreviated name for 13th month (if exists) + public const int LOCALE_SABBREVMONTHNAME13 = 0x0000100F; + + /// positive sign, eg "" + public const int LOCALE_SPOSITIVESIGN = 0x00000050; + /// negative sign, eg "-" + public const int LOCALE_SNEGATIVESIGN = 0x00000051; + /// positive sign position (derived from INEGCURR) + public const int LOCALE_IPOSSIGNPOSN = 0x00000052; + /// negative sign position (derived from INEGCURR) + public const int LOCALE_INEGSIGNPOSN = 0x00000053; + /// mon sym precedes pos amt (derived from ICURRENCY) + public const int LOCALE_IPOSSYMPRECEDES = 0x00000054; + /// mon sym sep by space from pos amt (derived from ICURRENCY) + public const int LOCALE_IPOSSEPBYSPACE = 0x00000055; + /// mon sym precedes neg amt (derived from INEGCURR) + public const int LOCALE_INEGSYMPRECEDES = 0x00000056; + /// mon sym sep by space from neg amt (derived from INEGCURR) + public const int LOCALE_INEGSEPBYSPACE = 0x00000057; + + /// font signature + public const int LOCALE_FONTSIGNATURE = 0x00000058; + /// ISO abbreviated language name, eg "en" + public const int LOCALE_SISO639LANGNAME = 0x00000059; + /// ISO abbreviated country/region name, eg "US" + public const int LOCALE_SISO3166CTRYNAME = 0x0000005A; + + + /// 1 = letter, 5 = legal, 8 = a3, 9 = a4 + public const int LOCALE_IPAPERSIZE = 0x0000100A; + /// english name of currency, eg "Euro" + public const int LOCALE_SENGCURRNAME = 0x00001007; + /// native name of currency, eg "euro" + public const int LOCALE_SNATIVECURRNAME = 0x00001008; + /// year month format string, eg "MM/yyyy" + public const int LOCALE_SYEARMONTH = 0x00001006; + /// sort name, usually "", eg "Dictionary" in UI Language + public const int LOCALE_SSORTNAME = 0x00001013; + /// 0 = context, 1 = none, 2 = national + public const int LOCALE_IDIGITSUBSTITUTION = 0x00001014; + + /// locale name (ie: en-us) + public const int LOCALE_SNAME = 0x0000005c; + /// time duration format, eg "hh:mm:ss" + public const int LOCALE_SDURATION = 0x0000005d; + /// Shortest day name for Monday + public const int LOCALE_SSHORTESTDAYNAME1 = 0x00000060; + /// Shortest day name for Tuesday + public const int LOCALE_SSHORTESTDAYNAME2 = 0x00000061; + /// Shortest day name for Wednesday + public const int LOCALE_SSHORTESTDAYNAME3 = 0x00000062; + /// Shortest day name for Thursday + public const int LOCALE_SSHORTESTDAYNAME4 = 0x00000063; + /// Shortest day name for Friday + public const int LOCALE_SSHORTESTDAYNAME5 = 0x00000064; + /// Shortest day name for Saturday + public const int LOCALE_SSHORTESTDAYNAME6 = 0x00000065; + /// Shortest day name for Sunday + public const int LOCALE_SSHORTESTDAYNAME7 = 0x00000066; + /// 3 character ISO abbreviated language name, eg "eng" + public const int LOCALE_SISO639LANGNAME2 = 0x00000067; + /// 3 character ISO country/region name, eg "USA" + public const int LOCALE_SISO3166CTRYNAME2 = 0x00000068; + /// Not a Number, eg "NaN" + public const int LOCALE_SNAN = 0x00000069; + /// + Infinity, eg "infinity" + public const int LOCALE_SPOSINFINITY = 0x0000006a; + /// - Infinity, eg "-infinity" + public const int LOCALE_SNEGINFINITY = 0x0000006b; + /// Typical scripts in the locale: ; delimited script codes, eg "Latn;" + public const int LOCALE_SSCRIPTS = 0x0000006c; + /// Fallback name for resources, eg "en" for "en-US" + public const int LOCALE_SPARENT = 0x0000006d; + /// Fallback name for within the console for Unicode Only locales, eg "en" for bn-IN + public const int LOCALE_SCONSOLEFALLBACKNAME = 0x0000006e; + + /// + /// Returns one of the following 4 reading layout values: + /// + /// ValueMeaning + /// 0 (zero)Left to right (eg en-US) + /// 1Right to left (eg arabic locales) + /// 2Vertical top to bottom with columns to the left and also left to right (ja-JP locales) + /// 3Vertical top to bottom with columns proceeding to the right + /// + /// + public const int LOCALE_IREADINGLAYOUT = 0x00000070; + /// Returns 0 for specific cultures, 1 for neutral cultures. + public const int LOCALE_INEUTRAL = 0x00000071; + /// Returns 0-11 for the negative percent format + public const int LOCALE_INEGATIVEPERCENT = 0x00000074; + /// Returns 0-3 for the positive percent formatIPOSITIVEPERCENT + public const int LOCALE_IPOSITIVEPERCENT = 0x00000075; + /// Returns the percent symbol + public const int LOCALE_SPERCENT = 0x00000076; + /// Returns the permille (U+2030) symbol + public const int LOCALE_SPERMILLE = 0x00000077; + /// Returns the preferred month/day format + public const int LOCALE_SMONTHDAY = 0x00000078; + /// Returns the preferred short time format (ie: no seconds, just h:mm) + public const int LOCALE_SSHORTTIME = 0x00000079; + /// Open type language tag, eg: "latn" or "dflt" + public const int LOCALE_SOPENTYPELANGUAGETAG = 0x0000007a; + /// Name of locale to use for sorting/collation/casing behavior. + public const int LOCALE_SSORTLOCALE = 0x0000007b; + + /// Long date without year, day of week, month, date, eg: for lock screen + public const int LOCALE_SRELATIVELONGDATE = 0x0000007c; + + /// Shortest AM designator, eg "A" + public const int LOCALE_SSHORTESTAM = 0x0000007e; + /// Shortest PM designator, eg "P" + public const int LOCALE_SSHORTESTPM = 0x0000007f; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 732 + // + // DEPRECATED LCTYPEs + // + + // DEPRECATED LCTYPEs for Code Pages + // Applications are strongly encouraged to Use Unicode, such as UTF-16 (WCHAR type) + // or the CP_UTF8 Code Page. Legacy encodings are unable to represent the full + // set of scripts/language and characters (& emoji!) available on modern computers. + // Use of legacy code pages (encodings) is a leading cause of data loss and corruption. + /// default oem code page for locale (user may configure as UTF-8, use of Unicode is recommended instead) + public const int LOCALE_IDEFAULTCODEPAGE = 0x0000000B; + /// default ansi code page for locale (user may configure as UTF-8, use of Unicode is recommended instead) + public const int LOCALE_IDEFAULTANSICODEPAGE = 0x00001004; + /// default mac code page for locale (user may configure as UTF-8, use of Unicode is recommended instead) + public const int LOCALE_IDEFAULTMACCODEPAGE = 0x00001011; + /// default ebcdic code page for a locale (use of Unicode is recommended instead) + public const int LOCALE_IDEFAULTEBCDICCODEPAGE = 0x00001012; + + // LCTYPEs using out-of-date concepts + [Obsolete("DEPRECATED language id (LCID), LOCALE_SNAME preferred")] + public const int LOCALE_ILANGUAGE = 0x00000001; + [Obsolete("DEPRECATED arbitrary abbreviated language name, LOCALE_SISO639LANGNAME instead.")] + public const int LOCALE_SABBREVLANGNAME = 0x00000003; + [Obsolete("DEPRECATED arbitrary abbreviated country/region name, LOCALE_SISO3166CTRYNAME instead.")] + public const int LOCALE_SABBREVCTRYNAME = 0x00000007; + [Obsolete("DEPRECATED geographical location id, use LOCALE_SISO3166CTRYNAME instead.")] + public const int LOCALE_IGEOID = 0x0000005B; + [Obsolete("DEPRECATED default language id, deprecated.")] + public const int LOCALE_IDEFAULTLANGUAGE = 0x00000009; + [Obsolete("DEPRECATED default country/region code, deprecated.")] + public const int LOCALE_IDEFAULTCOUNTRY = 0x0000000A; + [Obsolete("DEPRECATED, use LOCALE_ICURRDIGITS # intl monetary digits, eg 2 for $1.00.")] + public const int LOCALE_IINTLCURRDIGITS = 0x0000001A; + + // Derived legacy date & time values for compatibility only. + // Please use the appropriate date or time pattern instead. + // These can be misleading, for example a locale configured as 12h24m52s could have a time separator of "h". + [Obsolete("DEPRECATED date separator (derived from LOCALE_SSHORTDATE, use that instead)")] + public const int LOCALE_SDATE = 0x0000001D; + [Obsolete("DEPRECATED time separator (derived from LOCALE_STIMEFORMAT, use that instead)")] + public const int LOCALE_STIME = 0x0000001E; + [Obsolete("DEPRECATED short date format ordering (derived from LOCALE_SSHORTDATE, use that instead)")] + public const int LOCALE_IDATE = 0x00000021; + [Obsolete("DEPRECATED long date format ordering (derived from LOCALE_SLONGDATE, use that instead)")] + public const int LOCALE_ILDATE = 0x00000022; + [Obsolete("DEPRECATED time format specifier (derived from LOCALE_STIMEFORMAT, use that instead)")] + public const int LOCALE_ITIME = 0x00000023; + [Obsolete("DEPRECATED time marker position (derived from LOCALE_STIMEFORMAT, use that instead)")] + public const int LOCALE_ITIMEMARKPOSN = 0x00001005; + [Obsolete("DEPRECATED century format specifier (short date, LOCALE_SSHORTDATE is preferred)")] + public const int LOCALE_ICENTURY = 0x00000024; + [Obsolete("DEPRECATED leading zeros in time field (derived from LOCALE_STIMEFORMAT, use that instead)")] + public const int LOCALE_ITLZERO = 0x00000025; + [Obsolete("DEPRECATED leading zeros in day field (short date, LOCALE_SSHORTDATE is preferred)")] + public const int LOCALE_IDAYLZERO = 0x00000026; + [Obsolete("DEPRECATED leading zeros in month field (short date, LOCALE_SSHORTDATE is preferred)")] + public const int LOCALE_IMONLZERO = 0x00000027; + + /// Used internally, see GetKeyboardLayoutName() function + public const int LOCALE_SKEYBOARDSTOINSTALL = 0x0000005e; + + // LCTYPEs which have been renamed to enable more understandable source code. + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SLANGUAGE = LOCALE_SLOCALIZEDDISPLAYNAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SLANGDISPLAYNAME = LOCALE_SLOCALIZEDLANGUAGENAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SENGLANGUAGE = LOCALE_SENGLISHLANGUAGENAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SNATIVELANGNAME = LOCALE_SNATIVELANGUAGENAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SCOUNTRY = LOCALE_SLOCALIZEDCOUNTRYNAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SENGCOUNTRY = LOCALE_SENGLISHCOUNTRYNAME; + [Obsolete("DEPRECATED as new name is more readable.")] + public const int LOCALE_SNATIVECTRYNAME = LOCALE_SNATIVECOUNTRYNAME; + /// Deprecated synonym for LOCALE_IDIALINGCODE + [Obsolete("DEPRECATED: Use LOCALE_SISO3166CTRYNAME to query for a region identifier, LOCALE_ICOUNTRY is not a region identifier.")] + public const int LOCALE_ICOUNTRY = LOCALE_IDIALINGCODE; + [Obsolete("DEPRECATED: Please use LOCALE_SAM, which is more readable.")] + public const int LOCALE_S1159 = LOCALE_SAM; + [Obsolete("DEPRECATED: Please use LOCALE_SPM, which is more readable.")] + public const int LOCALE_S2359 = LOCALE_SPM; + + + // + // Time Flags for GetTimeFormat. + // + /// do not use minutes or seconds + public const int TIME_NOMINUTESORSECONDS = 0x00000001; + /// do not use seconds + public const int TIME_NOSECONDS = 0x00000002; + /// do not use time marker + public const int TIME_NOTIMEMARKER = 0x00000004; + /// always use 24 hour format + public const int TIME_FORCE24HOURFORMAT = 0x00000008; + + + // + // Date Flags for GetDateFormat. + // + /// use short date picture + public const int DATE_SHORTDATE = 0x00000001; + /// use long date picture + public const int DATE_LONGDATE = 0x00000002; + /// use alternate calendar (if any) + public const int DATE_USE_ALT_CALENDAR = 0x00000004; + + /// use year month picture + public const int DATE_YEARMONTH = 0x00000008; + /// add marks for left to right reading order layout + public const int DATE_LTRREADING = 0x00000010; + /// add marks for right to left reading order layout + public const int DATE_RTLREADING = 0x00000020; + + /// add appropriate marks for left-to-right or right-to-left reading order layout + public const int DATE_AUTOLAYOUT = 0x00000040; + + /// include month day pictures + public const int DATE_MONTHDAY = 0x00000080; + + // + // Calendar Types. + // + // These types are used for the EnumCalendarInfo and GetCalendarInfo + // NLS API routines. + // Some of these types are also used for the SetCalendarInfo NLS API + // routine. + // + + // + // The following CalTypes may be used in combination with any other CalTypes. + // + // CAL_NOUSEROVERRIDE + // + // CAL_RETURN_NUMBER will return the result from GetCalendarInfo as a + // number instead of a string. This flag is only valid for the CalTypes + // beginning with CAL_I. + // + // DEPRECATED: CAL_USE_CP_ACP is used in many of the A (Ansi) apis that need + // to do string translation. Callers are encouraged to use the W + // (WCHAR/Unicode) apis instead. + // + /// Not Recommended - do not use user overrides + public const int CAL_NOUSEROVERRIDE = LOCALE_NOUSEROVERRIDE; + [Obsolete("DEPRECATED, call Unicode APIs instead: use the system ACP.")] + public const int CAL_USE_CP_ACP = LOCALE_USE_CP_ACP; + /// return number instead of string + public const int CAL_RETURN_NUMBER = LOCALE_RETURN_NUMBER; + + /// return genitive forms of month names + public const int CAL_RETURN_GENITIVE_NAMES = LOCALE_RETURN_GENITIVE_NAMES; + + // + // The following CalTypes are mutually exclusive in that they may NOT + // be used in combination with each other. + // + /// calendar type + public const int CAL_ICALINTVALUE = 0x00000001; + /// native name of calendar + public const int CAL_SCALNAME = 0x00000002; + /// starting years of eras + public const int CAL_IYEAROFFSETRANGE = 0x00000003; + /// era name for IYearOffsetRanges, eg A.D. + public const int CAL_SERASTRING = 0x00000004; + /// short date format string + public const int CAL_SSHORTDATE = 0x00000005; + /// long date format string + public const int CAL_SLONGDATE = 0x00000006; + /// native name for Monday + public const int CAL_SDAYNAME1 = 0x00000007; + /// native name for Tuesday + public const int CAL_SDAYNAME2 = 0x00000008; + /// native name for Wednesday + public const int CAL_SDAYNAME3 = 0x00000009; + /// native name for Thursday + public const int CAL_SDAYNAME4 = 0x0000000a; + /// native name for Friday + public const int CAL_SDAYNAME5 = 0x0000000b; + /// native name for Saturday + public const int CAL_SDAYNAME6 = 0x0000000c; + /// native name for Sunday + public const int CAL_SDAYNAME7 = 0x0000000d; + /// abbreviated name for Mon + public const int CAL_SABBREVDAYNAME1 = 0x0000000e; + /// abbreviated name for Tue + public const int CAL_SABBREVDAYNAME2 = 0x0000000f; + /// abbreviated name for Wed + public const int CAL_SABBREVDAYNAME3 = 0x00000010; + /// abbreviated name for Thu + public const int CAL_SABBREVDAYNAME4 = 0x00000011; + /// abbreviated name for Fri + public const int CAL_SABBREVDAYNAME5 = 0x00000012; + /// abbreviated name for Sat + public const int CAL_SABBREVDAYNAME6 = 0x00000013; + /// abbreviated name for Sun + public const int CAL_SABBREVDAYNAME7 = 0x00000014; + // Note that in the hebrew calendar the leap month name is always returned as the 7th month + /// native name for January + public const int CAL_SMONTHNAME1 = 0x00000015; + /// native name for February + public const int CAL_SMONTHNAME2 = 0x00000016; + /// native name for March + public const int CAL_SMONTHNAME3 = 0x00000017; + /// native name for April + public const int CAL_SMONTHNAME4 = 0x00000018; + /// native name for May + public const int CAL_SMONTHNAME5 = 0x00000019; + /// native name for June + public const int CAL_SMONTHNAME6 = 0x0000001a; + /// native name for July + public const int CAL_SMONTHNAME7 = 0x0000001b; + /// native name for August + public const int CAL_SMONTHNAME8 = 0x0000001c; + /// native name for September + public const int CAL_SMONTHNAME9 = 0x0000001d; + /// native name for October + public const int CAL_SMONTHNAME10 = 0x0000001e; + /// native name for November + public const int CAL_SMONTHNAME11 = 0x0000001f; + /// native name for December + public const int CAL_SMONTHNAME12 = 0x00000020; + /// native name for 13th month (if any) + public const int CAL_SMONTHNAME13 = 0x00000021; + /// abbreviated name for Jan + public const int CAL_SABBREVMONTHNAME1 = 0x00000022; + /// abbreviated name for Feb + public const int CAL_SABBREVMONTHNAME2 = 0x00000023; + /// abbreviated name for Mar + public const int CAL_SABBREVMONTHNAME3 = 0x00000024; + /// abbreviated name for Apr + public const int CAL_SABBREVMONTHNAME4 = 0x00000025; + /// abbreviated name for May + public const int CAL_SABBREVMONTHNAME5 = 0x00000026; + /// abbreviated name for Jun + public const int CAL_SABBREVMONTHNAME6 = 0x00000027; + /// abbreviated name for July + public const int CAL_SABBREVMONTHNAME7 = 0x00000028; + /// abbreviated name for Aug + public const int CAL_SABBREVMONTHNAME8 = 0x00000029; + /// abbreviated name for Sep + public const int CAL_SABBREVMONTHNAME9 = 0x0000002a; + /// abbreviated name for Oct + public const int CAL_SABBREVMONTHNAME10 = 0x0000002b; + /// abbreviated name for Nov + public const int CAL_SABBREVMONTHNAME11 = 0x0000002c; + /// abbreviated name for Dec + public const int CAL_SABBREVMONTHNAME12 = 0x0000002d; + /// abbreviated name for 13th month (if any) + public const int CAL_SABBREVMONTHNAME13 = 0x0000002e; + + /// year month format string + public const int CAL_SYEARMONTH = 0x0000002f; + /// two digit year max + public const int CAL_ITWODIGITYEARMAX = 0x00000030; + + /// Shortest day name for Mo + public const int CAL_SSHORTESTDAYNAME1 = 0x00000031; + /// Shortest day name for Tu + public const int CAL_SSHORTESTDAYNAME2 = 0x00000032; + /// Shortest day name for We + public const int CAL_SSHORTESTDAYNAME3 = 0x00000033; + /// Shortest day name for Th + public const int CAL_SSHORTESTDAYNAME4 = 0x00000034; + /// Shortest day name for Fr + public const int CAL_SSHORTESTDAYNAME5 = 0x00000035; + /// Shortest day name for Sa + public const int CAL_SSHORTESTDAYNAME6 = 0x00000036; + /// Shortest day name for Su + public const int CAL_SSHORTESTDAYNAME7 = 0x00000037; + + /// Month/day format + public const int CAL_SMONTHDAY = 0x00000038; + /// Abbreviated era string (eg: AD) + public const int CAL_SABBREVERASTRING = 0x00000039; + + /// Long date without year, day of week, month, date, eg: for lock screen + public const int CAL_SRELATIVELONGDATE = 0x0000003a; + + /// Japanese calendar only: return the English era names for .Net compatibility + public const int CAL_SENGLISHERANAME = 0x0000003b; + /// Japanese calendar only: return the English Abbreviated era names for .Net compatibility + public const int CAL_SENGLISHABBREVERANAME = 0x0000003c; + + // + // Calendar Enumeration Value. + // + /// enumerate all calendars + public const int ENUM_ALL_CALENDARS = unchecked((int)0xffffffff); + + // + // Calendar ID Values. + // + /// Gregorian (localized) calendar + public const int CAL_GREGORIAN = 1; + /// Gregorian (U.S.) calendar + public const int CAL_GREGORIAN_US = 2; + /// Japanese Emperor Era calendar + public const int CAL_JAPAN = 3; + /// Taiwan calendar + public const int CAL_TAIWAN = 4; + /// Korean Tangun Era calendar + public const int CAL_KOREA = 5; + /// Hijri (Arabic Lunar) calendar + public const int CAL_HIJRI = 6; + /// Thai calendar + public const int CAL_THAI = 7; + /// Hebrew (Lunar) calendar + public const int CAL_HEBREW = 8; + /// Gregorian Middle East French calendar + public const int CAL_GREGORIAN_ME_FRENCH = 9; + /// Gregorian Arabic calendar + public const int CAL_GREGORIAN_ARABIC = 10; + /// Gregorian Transliterated English calendar + public const int CAL_GREGORIAN_XLIT_ENGLISH = 11; + /// Gregorian Transliterated French calendar + public const int CAL_GREGORIAN_XLIT_FRENCH = 12; + /// Persian (Solar Hijri) calendar + public const int CAL_PERSIAN = 22; + /// UmAlQura Hijri (Arabic Lunar) calendar + public const int CAL_UMALQURA = 23; + + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + // Language Group ID Values + // + // The "Language Group" concept is an obsolete concept. + // The groups returned are not well defined, arbitrary, inconsistent, inaccurate, + // no longer maintained, and no longer supported. + // + // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** + // + /// Western Europe & U.S. + public const int LGRPID_WESTERN_EUROPE = 0x0001; + /// Central Europe + public const int LGRPID_CENTRAL_EUROPE = 0x0002; + /// Baltic + public const int LGRPID_BALTIC = 0x0003; + /// Greek + public const int LGRPID_GREEK = 0x0004; + /// Cyrillic + public const int LGRPID_CYRILLIC = 0x0005; + /// Turkic + public const int LGRPID_TURKIC = 0x0006; + /// Turkish + public const int LGRPID_TURKISH = 0x0006; + /// Japanese + public const int LGRPID_JAPANESE = 0x0007; + /// Korean + public const int LGRPID_KOREAN = 0x0008; + /// Traditional Chinese + public const int LGRPID_TRADITIONAL_CHINESE = 0x0009; + /// Simplified Chinese + public const int LGRPID_SIMPLIFIED_CHINESE = 0x000a; + /// Thai + public const int LGRPID_THAI = 0x000b; + /// Hebrew + public const int LGRPID_HEBREW = 0x000c; + /// Arabic + public const int LGRPID_ARABIC = 0x000d; + /// Vietnamese + public const int LGRPID_VIETNAMESE = 0x000e; + /// Indic + public const int LGRPID_INDIC = 0x000f; + /// Georgian + public const int LGRPID_GEORGIAN = 0x0010; + /// Armenian + public const int LGRPID_ARMENIAN = 0x0011; + + + // + // MUI function flag values + // + /// Use traditional language ID convention + public const int MUI_LANGUAGE_ID = 0x4; + /// Use ISO language (culture) name convention + public const int MUI_LANGUAGE_NAME = 0x8; + /// GetThreadPreferredUILanguages merges in parent and base languages + public const int MUI_MERGE_SYSTEM_FALLBACK = 0x10; + /// GetThreadPreferredUILanguages merges in user preferred languages + public const int MUI_MERGE_USER_FALLBACK = 0x20; + public const int MUI_UI_FALLBACK = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK; + /// GetThreadPreferredUILanguages merges in user preferred languages + public const int MUI_THREAD_LANGUAGES = 0x40; + /// SetThreadPreferredUILanguages takes on console specific behavior + public const int MUI_CONSOLE_FILTER = 0x100; + /// SetThreadPreferredUILanguages takes on complex script specific behavior + public const int MUI_COMPLEX_SCRIPT_FILTER = 0x200; + /// Reset MUI_CONSOLE_FILTER and MUI_COMPLEX_SCRIPT_FILTER + public const int MUI_RESET_FILTERS = 0x001; + /// GetFileMUIPath returns the MUI files for the languages in the fallback list + public const int MUI_USER_PREFERRED_UI_LANGUAGES = 0x10; + /// GetFileMUIPath returns all the MUI files installed in the machine + public const int MUI_USE_INSTALLED_LANGUAGES = 0x20; + /// GetFileMUIPath returns all the MUI files irrespective of whether language is installed + public const int MUI_USE_SEARCH_ALL_LANGUAGES = 0x40; + /// GetFileMUIPath returns target file with .mui extension + public const int MUI_LANG_NEUTRAL_PE_FILE = 0x100; + /// GetFileMUIPath returns target file with same name as source + public const int MUI_NON_LANG_NEUTRAL_FILE = 0x200; + public const int MUI_MACHINE_LANGUAGE_SETTINGS = 0x400; + /// GetFileMUIInfo found a non-split resource file + public const int MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = 0x001; + /// GetFileMUIInfo found a LN main module resource file + public const int MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002; + /// GetFileMUIInfo found a LN MUI module resource file + public const int MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = 0x004; + /// GetFileMUIInfo will look for the type of the resource file + public const int MUI_QUERY_TYPE = 0x001; + /// GetFileMUIInfo will look for the checksum of the resource file + public const int MUI_QUERY_CHECKSUM = 0x002; + /// GetFileMUIInfo will look for the culture of the resource file + public const int MUI_QUERY_LANGUAGE_NAME = 0x004; + /// GetFileMUIInfo will look for the resource types of the resource file + public const int MUI_QUERY_RESOURCE_TYPES = 0x008; + /// Version of FILEMUIINFO structure used with GetFileMUIInfo + public const int MUI_FILEINFO_VERSION = 0x001; + + public const int MUI_FULL_LANGUAGE = 0x01; + public const int MUI_PARTIAL_LANGUAGE = 0x02; + public const int MUI_LIP_LANGUAGE = 0x04; + public const int MUI_LANGUAGE_INSTALLED = 0x20; + public const int MUI_LANGUAGE_LICENSED = 0x40; } } From 7656aa6a182475bcd488944ec09f31123bda6d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 18:53:34 +0200 Subject: [PATCH 11/50] Add Win NLS deprecations, winnls.h --- .../WinNlsConstants.cs | 141 +++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 98707ac6..276b45f8 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -431,229 +431,346 @@ public static class WinNlsConstants // // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** // + private const string GEOID_DEPRECATION_MESSAGE = + "DEPRECATED: The GEOID concept is deprecated, please use " + + "Country/Region Names instead, eg: \"US\" instead of a GEOID like 244. " + + "See the documentation for GetGeoInfoEx."; + + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_DEFAULT = 0; /// Albania + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ALBANIA = 355; /// Algeria + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ALGERIA = 213; /// Argentina + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ARGENTINA = 54; /// Armenia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ARMENIA = 374; /// Australia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_AUSTRALIA = 61; /// Austria + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_AUSTRIA = 43; /// Azerbaijan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_AZERBAIJAN = 994; /// Bahrain + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BAHRAIN = 973; /// Belarus + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BELARUS = 375; /// Belgium + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BELGIUM = 32; /// Belize + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BELIZE = 501; /// Bolivia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BOLIVIA = 591; /// Brazil + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BRAZIL = 55; /// Brunei Darussalam + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BRUNEI_DARUSSALAM = 673; /// Bulgaria + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_BULGARIA = 359; /// Canada + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_CANADA = 2; /// Caribbean + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_CARIBBEAN = 1; /// Chile + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_CHILE = 56; /// Colombia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_COLOMBIA = 57; /// Costa Rica + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_COSTA_RICA = 506; /// Croatia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_CROATIA = 385; /// Czech Republic + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_CZECH = 420; /// Denmark + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_DENMARK = 45; /// Dominican Republic + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_DOMINICAN_REPUBLIC = 1; /// Ecuador + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ECUADOR = 593; /// Egypt + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_EGYPT = 20; /// El Salvador + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_EL_SALVADOR = 503; /// Estonia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ESTONIA = 372; /// Faeroe Islands + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_FAEROE_ISLANDS = 298; /// Finland + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_FINLAND = 358; /// France + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_FRANCE = 33; /// Georgia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_GEORGIA = 995; /// Germany + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_GERMANY = 49; /// Greece + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_GREECE = 30; /// Guatemala + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_GUATEMALA = 502; /// Honduras + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_HONDURAS = 504; /// Hong Kong S.A.R., P.R.C. + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_HONG_KONG = 852; /// Hungary + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_HUNGARY = 36; /// Iceland + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ICELAND = 354; /// India + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_INDIA = 91; /// Indonesia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_INDONESIA = 62; /// Iran + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_IRAN = 981; /// Iraq + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_IRAQ = 964; /// Ireland + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_IRELAND = 353; /// Israel + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ISRAEL = 972; /// Italy + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ITALY = 39; /// Jamaica + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_JAMAICA = 1; /// Japan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_JAPAN = 81; /// Jordan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_JORDAN = 962; /// Kazakstan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_KAZAKSTAN = 7; /// Kenya + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_KENYA = 254; /// Kuwait + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_KUWAIT = 965; /// Kyrgyzstan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_KYRGYZSTAN = 996; /// Latvia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LATVIA = 371; /// Lebanon + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LEBANON = 961; /// Libya + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LIBYA = 218; /// Liechtenstein + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LIECHTENSTEIN = 41; /// Lithuania + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LITHUANIA = 370; /// Luxembourg + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_LUXEMBOURG = 352; /// Macao SAR, PRC + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MACAU = 853; /// Former Yugoslav Republic of Macedonia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MACEDONIA = 389; /// Malaysia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MALAYSIA = 60; /// Maldives + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MALDIVES = 960; /// Mexico + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MEXICO = 52; /// Principality of Monaco + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MONACO = 33; /// Mongolia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MONGOLIA = 976; /// Morocco + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_MOROCCO = 212; /// Netherlands + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_NETHERLANDS = 31; /// New Zealand + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_NEW_ZEALAND = 64; /// Nicaragua + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_NICARAGUA = 505; /// Norway + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_NORWAY = 47; /// Oman + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_OMAN = 968; /// Islamic Republic of Pakistan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PAKISTAN = 92; /// Panama + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PANAMA = 507; /// Paraguay + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PARAGUAY = 595; /// Peru + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PERU = 51; /// Republic of the Philippines + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PHILIPPINES = 63; /// Poland + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_POLAND = 48; /// Portugal + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PORTUGAL = 351; /// People's Republic of China + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PRCHINA = 86; /// Puerto Rico + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_PUERTO_RICO = 1; /// Qatar + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_QATAR = 974; /// Romania + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ROMANIA = 40; /// Russia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_RUSSIA = 7; /// Saudi Arabia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SAUDI_ARABIA = 966; /// Serbia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SERBIA = 381; /// Singapore + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SINGAPORE = 65; /// Slovak Republic + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SLOVAK = 421; /// Slovenia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SLOVENIA = 386; /// South Africa + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SOUTH_AFRICA = 27; /// Korea + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SOUTH_KOREA = 82; /// Spain + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SPAIN = 34; /// Sweden + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SWEDEN = 46; /// Switzerland + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SWITZERLAND = 41; /// Syria + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_SYRIA = 963; /// Taiwan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_TAIWAN = 886; /// Tatarstan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_TATARSTAN = 7; /// Thailand + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_THAILAND = 66; /// Trinidad y Tobago + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_TRINIDAD_Y_TOBAGO = 1; /// Tunisia + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_TUNISIA = 216; /// Turkey + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_TURKEY = 90; /// U.A.E. + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_UAE = 971; /// Ukraine + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_UKRAINE = 380; /// United Kingdom + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_UNITED_KINGDOM = 44; /// United States + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_UNITED_STATES = 1; /// Uruguay + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_URUGUAY = 598; /// Uzbekistan + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_UZBEKISTAN = 7; /// Venezuela + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_VENEZUELA = 58; /// Viet Nam + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_VIET_NAM = 84; /// Yemen + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_YEMEN = 967; /// Zimbabwe + [Obsolete(GEOID_DEPRECATION_MESSAGE)] public const int CTRY_ZIMBABWE = 263; // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 528 @@ -1309,44 +1426,66 @@ public static class WinNlsConstants // // ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** DEPRECATED ** // + public const string LGRPID_DEPRECATION_MESSAGE = + "The \"Language Group\" concept is an obsolete concept." + "\r\n" + + "The groups returned are not well defined, arbitrary, inconsistent, inaccurate, " + + "no longer maintained, and no longer supported."; + /// Western Europe & U.S. + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_WESTERN_EUROPE = 0x0001; /// Central Europe + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_CENTRAL_EUROPE = 0x0002; /// Baltic + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_BALTIC = 0x0003; /// Greek + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_GREEK = 0x0004; /// Cyrillic + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_CYRILLIC = 0x0005; /// Turkic + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_TURKIC = 0x0006; /// Turkish + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_TURKISH = 0x0006; /// Japanese + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_JAPANESE = 0x0007; /// Korean + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_KOREAN = 0x0008; /// Traditional Chinese + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_TRADITIONAL_CHINESE = 0x0009; /// Simplified Chinese + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_SIMPLIFIED_CHINESE = 0x000a; /// Thai + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_THAI = 0x000b; /// Hebrew + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_HEBREW = 0x000c; /// Arabic + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_ARABIC = 0x000d; /// Vietnamese + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_VIETNAMESE = 0x000e; /// Indic + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_INDIC = 0x000f; /// Georgian + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_GEORGIAN = 0x0010; /// Armenian + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] public const int LGRPID_ARMENIAN = 0x0011; - // // MUI function flag values // From 5d12c986550e2c5ff104986bd06f3808a2792d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 19:12:06 +0200 Subject: [PATCH 12/50] LGRPID typedef, winnls.h line 1053 --- .../THNETII.WinApi.Headers.WinNls/LGRPID.cs | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/LGRPID.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LGRPID.cs b/src-native/THNETII.WinApi.Headers.WinNls/LGRPID.cs new file mode 100644 index 00000000..4bbc7e45 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/LGRPID.cs @@ -0,0 +1,61 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + using static WinNlsConstants; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1042 + /// + /// Language Group ID + /// + [Obsolete(LGRPID_DEPRECATION_MESSAGE)] + [StructLayout(LayoutKind.Sequential)] + public struct LGRPID : IEquatable, IEquatable + { + public LGRPID(int value) : this() => Value = value; + + public int Value { get; } + + public override bool Equals(object obj) => obj switch + { + int value => Equals(value), + LGRPID other => Equals(other), + null => false, + _ => false + }; + + public bool Equals(LGRPID other) => Value.Equals(other.Value); + + public bool Equals(int other) => Value.Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public static bool operator ==(LGRPID left, LGRPID right) => + left.Equals(right); + + public static bool operator !=(LGRPID left, LGRPID right) => + !(left == right); + + public static bool operator ==(LGRPID left, int right) => + left.Equals(right); + + public static bool operator !=(LGRPID left, int right) => + !(left == right); + + public static bool operator ==(int left, LGRPID right) => + left.Equals(right.Value); + + public static bool operator !=(int left, LGRPID right) => + !(left == right); + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(LGRPID))] + public static explicit operator LGRPID(int value) => + new LGRPID(value); + + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(Value))] + public static implicit operator int(LGRPID lgrpid) => lgrpid.Value; + } +} From d5743c948684a98c2271e9704076c24e195067b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 19:13:49 +0200 Subject: [PATCH 13/50] LCTYPE typedef, winnls.h line 1058 --- .../THNETII.WinApi.Headers.WinNls/LCTYPE.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/LCTYPE.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LCTYPE.cs b/src-native/THNETII.WinApi.Headers.WinNls/LCTYPE.cs new file mode 100644 index 00000000..43ad0726 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/LCTYPE.cs @@ -0,0 +1,58 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1055 + /// + /// Locale type constant. + /// + [StructLayout(LayoutKind.Sequential)] + public struct LCTYPE : IEquatable, IEquatable + { + public LCTYPE(int value) : this() => Value = value; + + public int Value { get; } + + public override bool Equals(object obj) => obj switch + { + int value => Equals(value), + LCTYPE other => Equals(other), + null => false, + _ => false + }; + + public bool Equals(LCTYPE other) => Value.Equals(other.Value); + + public bool Equals(int other) => Value.Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public static bool operator ==(LCTYPE left, LCTYPE right) => + left.Equals(right); + + public static bool operator !=(LCTYPE left, LCTYPE right) => + !(left == right); + + public static bool operator ==(LCTYPE left, int right) => + left.Equals(right); + + public static bool operator !=(LCTYPE left, int right) => + !(left == right); + + public static bool operator ==(int left, LCTYPE right) => + left.Equals(right.Value); + + public static bool operator !=(int left, LCTYPE right) => + !(left == right); + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(LCTYPE))] + public static explicit operator LCTYPE(int value) => + new LCTYPE(value); + + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(Value))] + public static implicit operator int(LCTYPE LCTYPE) => LCTYPE.Value; + } +} From 5d211663c6e67a98ee7b08c87208ae997e7dc7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 19:14:45 +0200 Subject: [PATCH 14/50] CALTYPE typedef, winnls.h line 1063 --- .../THNETII.WinApi.Headers.WinNls/CALTYPE.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CALTYPE.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CALTYPE.cs b/src-native/THNETII.WinApi.Headers.WinNls/CALTYPE.cs new file mode 100644 index 00000000..4b28c4bb --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CALTYPE.cs @@ -0,0 +1,58 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1060 + /// + /// Calendar type constant. + /// + [StructLayout(LayoutKind.Sequential)] + public struct CALTYPE : IEquatable, IEquatable + { + public CALTYPE(int value) : this() => Value = value; + + public int Value { get; } + + public override bool Equals(object obj) => obj switch + { + int value => Equals(value), + CALTYPE other => Equals(other), + null => false, + _ => false + }; + + public bool Equals(CALTYPE other) => Value.Equals(other.Value); + + public bool Equals(int other) => Value.Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public static bool operator ==(CALTYPE left, CALTYPE right) => + left.Equals(right); + + public static bool operator !=(CALTYPE left, CALTYPE right) => + !(left == right); + + public static bool operator ==(CALTYPE left, int right) => + left.Equals(right); + + public static bool operator !=(CALTYPE left, int right) => + !(left == right); + + public static bool operator ==(int left, CALTYPE right) => + left.Equals(right.Value); + + public static bool operator !=(int left, CALTYPE right) => + !(left == right); + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(CALTYPE))] + public static explicit operator CALTYPE(int value) => + new CALTYPE(value); + + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(Value))] + public static implicit operator int(CALTYPE CALTYPE) => CALTYPE.Value; + } +} From c9e958140bb0ba87063f911114a5a6292a3d6986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 19:15:43 +0200 Subject: [PATCH 15/50] CALID typedef, winnls.h line 1069 --- .../THNETII.WinApi.Headers.WinNls/CALID.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CALID.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CALID.cs b/src-native/THNETII.WinApi.Headers.WinNls/CALID.cs new file mode 100644 index 00000000..5cdd94ab --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CALID.cs @@ -0,0 +1,58 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1066 + /// + /// Calendar ID. + /// + [StructLayout(LayoutKind.Sequential)] + public struct CALID : IEquatable, IEquatable + { + public CALID(int value) : this() => Value = value; + + public int Value { get; } + + public override bool Equals(object obj) => obj switch + { + int value => Equals(value), + CALID other => Equals(other), + null => false, + _ => false + }; + + public bool Equals(CALID other) => Value.Equals(other.Value); + + public bool Equals(int other) => Value.Equals(other); + + public override int GetHashCode() => Value.GetHashCode(); + + public static bool operator ==(CALID left, CALID right) => + left.Equals(right); + + public static bool operator !=(CALID left, CALID right) => + !(left == right); + + public static bool operator ==(CALID left, int right) => + left.Equals(right); + + public static bool operator !=(CALID left, int right) => + !(left == right); + + public static bool operator ==(int left, CALID right) => + left.Equals(right.Value); + + public static bool operator !=(int left, CALID right) => + !(left == right); + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(CALID))] + public static explicit operator CALID(int value) => + new CALID(value); + + + [SuppressMessage("Usage", "CA2225: Operator overloads have named alternates", Justification = nameof(Value))] + public static implicit operator int(CALID CALID) => CALID.Value; + } +} From eaea6d5bafb958a2e1d79c72326e1f8b023a816b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Fri, 17 Apr 2020 20:25:08 +0200 Subject: [PATCH 16/50] CPINFO structure, winnls.h line 1085 --- .../THNETII.WinApi.Headers.WinNls/CPINFO.cs | 70 +++++++++++++++++++ .../GlobalSuppressions.cs | 11 +++ .../THNETII.WinApi.Headers.WinNls.csproj | 7 +- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CPINFO.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CPINFO.cs b/src-native/THNETII.WinApi.Headers.WinNls/CPINFO.cs new file mode 100644 index 00000000..75481b2a --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CPINFO.cs @@ -0,0 +1,70 @@ +using System; +using System.Runtime.InteropServices; +using THNETII.InteropServices.Memory; + +namespace THNETII.WinApi.Native.WinNls +{ + using static WinNlsConstants; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1072 + // + // CP Info. + // + // Deprecated. Applications should use Unicode (WCHAR / UTF-16 or UTF-8) + // + // WARNING: These structures fail for some encodings, including UTF-8, which + // do not fit into the assumptions of these APIs. + // + /// + /// Contains information about a code page. This structure is used by the function. + /// + /// + /// Lead bytes are unique to DBCS code pages that allow for more than 256 characters. A lead byte is the first byte of a 2-byte character in a DBCS. On each DBCS code page, the lead bytes occupy a specific range of byte values. This range is different for different code pages. + /// The lead byte information is not very helpful for most code pages, and is not even provided for many multi-byte encodings, for example, UTF-8 and GB18030. Your applications are discouraged from using this information to predict what the or function will do. The function might end up using a default character or performing other default behavior if the bytes following the lead byte are not as expected. + /// , used by the function, provides an extended version of this structure. + /// Microsoft Docs page: CPINFO structure + /// + /// + /// + /// + /// National Language Support Structures + /// + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accurately and may be unreliable on many machines.")] + [StructLayout(LayoutKind.Sequential)] + public unsafe struct CPINFO + { + /// + /// Maximum length, in bytes, of a character in the code page. The length can be 1 for a single-byte character set (SBCS), 2 for a double-byte character set (DBCS), or a value larger than 2 for other character set types. The function cannot use the size to distinguish an SBCS or a DBCS from other character sets because of other factors, for example, the use of ISCII or ISO-2022-xx code pages. + /// + public int MaxCharSize; // max length (in bytes) of a char + #region public fixed byte DefaultChar[MAX_DEFAULTCHAR]; + internal fixed byte DefaultCharPtr[MAX_DEFAULTCHAR]; // default character + /// + /// Default character used when translating character strings to the specific code page. This character is used by the function if an explicit default character is not specified. The default is usually the '?' character for the code page. + /// + public Span DefaultChar + { + get + { + fixed (void* ptr = DefaultCharPtr) + return new Span(ptr, MAX_DEFAULTCHAR); + } + } + #endregion + #region public fixed byte LeadByte[MAX_LEADBYTES]; + internal fixed byte LeadBytePtr[MAX_LEADBYTES]; // lead byte ranges + /// + /// A fixed-length array of lead byte ranges, for which the number of lead byte ranges is variable. If the code page has no lead bytes, every element of the array is set to 0 (zero). If the code page has lead bytes, the array specifies a starting value and an ending value for each range. Ranges are inclusive, and the maximum number of ranges for any code page is five. The array uses two bytes to describe each range, with two null bytes as a terminator after the last range. + /// Some code pages use lead bytes and a combination of other encoding mechanisms. This member is usually only populated for a subset of the code pages that use lead bytes in some form. For more information, see the Remarks section. + /// + public Span LeadByte + { + get + { + fixed (void* ptr = LeadBytePtr) + return new Span(ptr, MAX_LEADBYTES); + } + } + #endregion + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs new file mode 100644 index 00000000..d69967e6 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs @@ -0,0 +1,11 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Design", + "CA1051: Do not declare visible instance fields")] +[assembly: SuppressMessage("Performance", + "CA1815: Override equals and operator equals on value types")] diff --git a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj index 88bb3e2f..1c606235 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj +++ b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj @@ -2,13 +2,18 @@ + true 8 - netstandard1.0;netstandard2.0 + netstandard1.3;netstandard2.0 true $(NoWarn);CS1591;CS0419 THNETII.WinApi.Native.WinNls + + + + All From f0f310262f013f7560a6b62ec5052ad883814283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 00:13:12 +0200 Subject: [PATCH 17/50] Add Fixed String buffer marshalling accelerators for ANSI and Unicode --- .../FixedStringBuffer.cs | 88 ++++++++++++++++++- .../THNETII.WinApi.Helpers.csproj | 4 +- 2 files changed, 86 insertions(+), 6 deletions(-) diff --git a/src-shared/THNETII.WinApi.Helpers/FixedStringBuffer.cs b/src-shared/THNETII.WinApi.Helpers/FixedStringBuffer.cs index fedf97b2..fa34b329 100644 --- a/src-shared/THNETII.WinApi.Helpers/FixedStringBuffer.cs +++ b/src-shared/THNETII.WinApi.Helpers/FixedStringBuffer.cs @@ -1,8 +1,10 @@ -using System; +using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Text; +using THNETII.InteropServices.Memory; + namespace THNETII.WinApi.Helpers { /// @@ -55,6 +57,84 @@ public static unsafe void ToBytesZeroTerminated(string str, byte* bytes, int max } } + /// + /// Marshals the specified byte-buffer to a managed value using + /// ANSI marshaling rules. + /// + /// A pointer to the first byte in the byte-buffer. This pointer should be a pointer that is initialized using a block. + /// The maximum length of the buffer pointed to by . + /// A containing a copy of the data pointed to by . + /// + /// The returned string can be at most characters long. + /// A null-terminating byte within the buffer will be interpreted as the end of the string. + /// + public static unsafe string ToStringZeroTerminatedAnsi(byte* bytes, int maxLength) + { + Span byteSpan = new Span(bytes, maxLength); + int len = byteSpan.IndexOf((byte)0); + if (len < 0) + len = maxLength; + return Marshal.PtrToStringAnsi((IntPtr)bytes, len); + } + + /// + /// Marshals the specified byte-buffer to a managed value using + /// Unicode (UTF-16) marshaling rules. + /// + /// A pointer to the first byte in the byte-buffer. This pointer should be a pointer that is initialized using a block. + /// The maximum length of the buffer pointed to by . + /// A containing a copy of the data pointed to by . + /// + /// The returned string can be at most characters long. + /// A null-terminating byte within the buffer will be interpreted as the end of the string. + /// + public static unsafe string ToStringZeroTerminatedUnicode(char* chars, int maxLength) + { + Span byteSpan = new Span(chars, maxLength); + int len = byteSpan.IndexOf((char)0); + if (len < 0) + len = maxLength; + return Marshal.PtrToStringUni((IntPtr)chars, len); + } + + /// + /// Marshals the specified byte-buffer to a managed value using + /// Platform dependent string marshaling rules. + /// + /// A pointer to the first byte in the byte-buffer. This pointer should be a pointer that is initialized using a block. + /// The maximum length of the buffer pointed to by . + /// A containing a copy of the data pointed to by . + /// + /// The returned string can be at most characters long. + /// A null-terminating byte within the buffer will be interpreted as the end of the string. + /// + public static unsafe ReadOnlyMemory ToStringZeroTerminatedAuto(byte* bytes, int maxLength) + { +#if NETSTANDARD1_3 + return Marshal.SystemDefaultCharSize switch + { + 1 => ToStringZeroTerminatedAnsi(bytes, maxLength).AsMemory(), + 2 => ToStringZeroTerminatedUnicode((char*)bytes, maxLength).AsMemory(), + _ => throw new PlatformNotSupportedException() + }; +#else + string str = Marshal.PtrToStringAuto(new IntPtr(bytes), maxLength); + if (str is null) + return Memory.Empty; + int endIdx = +#if NETCOREAPP + str.IndexOf((char)0, StringComparison.Ordinal) +#else + str.IndexOf((char)0) +#endif + ; + if (endIdx < 0) + return str.AsMemory(); + else + return str.AsMemory(0, endIdx); +#endif + } + /// public static unsafe string MarshalAnsiString(byte* bytes) { @@ -128,10 +208,10 @@ public static unsafe void MarshalAnsiBytes(string str, byte* bytes, int maxLengt IntPtr pStr = Marshal.StringToCoTaskMemAnsi(str); try { - var valueSpan = new Span(pStr.ToPointer(), maxLength); + var valueSpan = pStr.ToZeroTerminatedByteSpan(); int endIdx = valueSpan.IndexOf((byte)0); - if (endIdx >= 0) - valueSpan = valueSpan.Slice(start: 0, length: endIdx + 1); + if (valueSpan.Length >= maxLength) + valueSpan = valueSpan.Slice(start: 0, length: maxLength); valueSpan.CopyTo(byteSpan); } finally diff --git a/src-shared/THNETII.WinApi.Helpers/THNETII.WinApi.Helpers.csproj b/src-shared/THNETII.WinApi.Helpers/THNETII.WinApi.Helpers.csproj index cb069993..8527f4c1 100644 --- a/src-shared/THNETII.WinApi.Helpers/THNETII.WinApi.Helpers.csproj +++ b/src-shared/THNETII.WinApi.Helpers/THNETII.WinApi.Helpers.csproj @@ -1,8 +1,8 @@ - + - 7.3 + 8 true netstandard1.3;netstandard2.0;netcoreapp3.0 true From a5dd8e559acb9e798a34dedd62261aa827f7803b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 00:15:05 +0200 Subject: [PATCH 18/50] CPINFOEX structures, winnls.h line 1112 --- .../THNETII.WinApi.Headers.WinNls/CPINFOEX.cs | 238 ++++++++++++++++++ .../THNETII.WinApi.Headers.WinNls.csproj | 11 +- 2 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CPINFOEX.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CPINFOEX.cs b/src-native/THNETII.WinApi.Headers.WinNls/CPINFOEX.cs new file mode 100644 index 00000000..f6674f53 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CPINFOEX.cs @@ -0,0 +1,238 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using THNETII.InteropServices.Memory; +using THNETII.WinApi.Helpers; +using THNETII.WinApi.Native.MinWinDef; + +namespace THNETII.WinApi.Native.WinNls +{ + using static MinWinDefConstants; + using static WinNlsConstants; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1088 + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accurately and may be unreliable on many machines.")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public unsafe struct CPINFOEXA + { + /// + public int MaxCharSize; // max length (in bytes) of a char + #region public fixed byte DefaultChar[MAX_DEFAULTCHAR]; + internal fixed byte DefaultCharPtr[MAX_DEFAULTCHAR]; // default character + /// + public Span DefaultChar + { + get + { + fixed (void* ptr = DefaultCharPtr) + return new Span(ptr, MAX_DEFAULTCHAR); + } + } + #endregion + #region public fixed byte LeadByte[MAX_LEADBYTES]; + internal fixed byte LeadBytePtr[MAX_LEADBYTES]; // lead byte ranges + /// + public Span LeadByte + { + get + { + fixed (void* ptr = LeadBytePtr) + return new Span(ptr, MAX_LEADBYTES); + } + } + #endregion + /// + public char UnicodeDefaultChar; // default character (Unicode) + /// + public int CodePage; // code page id + #region public fixed byte CodePageName[MAX_PATH]; + internal fixed byte CodePageNamePtr[MAX_PATH]; + public Span CodePageNameSpan + { + get + { + fixed (byte* ptr = CodePageNamePtr) + return new Span(ptr, MAX_PATH); + } + } + + /// + public string CodePageName // code page name (Unicode) + { + get + { + fixed (byte* ptr = CodePageNamePtr) + return FixedStringBuffer.ToStringZeroTerminatedAnsi(ptr, MAX_PATH); + } + set + { + fixed (byte* ptr = CodePageNamePtr) + FixedStringBuffer.MarshalAnsiBytes(value, ptr, MAX_PATH); + } + } + #endregion + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1097 + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accurately and may be unreliable on many machines.")] + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public unsafe struct CPINFOEXW + { + /// + public int MaxCharSize; // max length (in bytes) of a char + #region public fixed byte DefaultChar[MAX_DEFAULTCHAR]; + internal fixed byte DefaultCharPtr[MAX_DEFAULTCHAR]; // default character + /// + public Span DefaultChar + { + get + { + fixed (void* ptr = DefaultCharPtr) + return new Span(ptr, MAX_DEFAULTCHAR); + } + } + #endregion + #region public fixed byte LeadByte[MAX_LEADBYTES]; + internal fixed byte LeadBytePtr[MAX_LEADBYTES]; // lead byte ranges + /// + public Span LeadByte + { + get + { + fixed (void* ptr = LeadBytePtr) + return new Span(ptr, MAX_LEADBYTES); + } + } + #endregion + /// + public char UnicodeDefaultChar; // default character (Unicode) + /// + public int CodePage; // code page id + #region public fixed byte CodePageName[MAX_PATH]; + internal fixed char CodePageNamePtr[MAX_PATH]; + public Span CodePageNameSpan + { + get + { + fixed (char* ptr = CodePageNamePtr) + return new Span(ptr, MAX_PATH); + } + } + + /// + public string CodePageName // code page name (Unicode) + { + get + { + fixed (char* ptr = CodePageNamePtr) + return FixedStringBuffer.ToStringZeroTerminatedUnicode(ptr, MAX_PATH); + } + set + { + fixed (char* ptr = CodePageNamePtr) + FixedStringBuffer.MarshalUnicodeChars(value, ptr, MAX_PATH); + } + } + #endregion + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1106 + /// + /// Contains information about a code page. This structure is used by the function. + /// + /// + /// Lead bytes are unique to DBCS code pages that allow for more than 256 characters. A lead byte is the first byte of a 2-byte character in a DBCS. On each DBCS code page, the lead bytes occupy a specific range of byte values. This range is different for different code pages. + /// The lead byte information is not very helpful for most code pages, and is not even provided for many multi-byte encodings, for example, UTF-8 and GB18030. Your applications are discouraged from using this information to predict what the or function will do. The function might end up using a default character or performing other default behavior if the bytes following the lead byte are not as expected. + /// Microsoft Docs page: CPINFOEXW structure + /// + /// + /// + /// National Language Support Structures + /// + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accurately and may be unreliable on many machines.")] +#if NETSTANDARD1_3 + [StructLayout(LayoutKind.Sequential)] +#else + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] +#endif + public unsafe struct CPINFOEX + { + /// + public int MaxCharSize; // max length (in bytes) of a char + #region public fixed byte DefaultChar[MAX_DEFAULTCHAR]; + internal fixed byte DefaultCharPtr[MAX_DEFAULTCHAR]; // default character + /// + public Span DefaultChar + { + get + { + fixed (void* ptr = DefaultCharPtr) + return new Span(ptr, MAX_DEFAULTCHAR); + } + } + #endregion + #region public fixed byte LeadByte[MAX_LEADBYTES]; + internal fixed byte LeadBytePtr[MAX_LEADBYTES]; // lead byte ranges + /// + public Span LeadByte + { + get + { + fixed (void* ptr = LeadBytePtr) + return new Span(ptr, MAX_LEADBYTES); + } + } + #endregion + /// + /// Unicode default character used in translations from the specific code page. The default is usually the ? character or the katakana middle dot character. The Unicode default character is used by the function. + /// + public char UnicodeDefaultChar; // default character (Unicode) + /// + /// Code page value. This value reflects the code page passed to the function. See Code Page Identifiers for a list of ANSI and other code pages. + /// + public int CodePage; // code page id + #region public fixed byte CodePageName[MAX_PATH]; + private fixed char CodePageNamePtr[MAX_PATH]; + /// + /// Full name of the code page. Note that this name is localized and is not guaranteed for uniqueness or consistency between operating system versions or computers. + /// + public string CodePageName // code page name (Unicode) + { + get + { + fixed (void* thisPtr = &this) + { + switch (Marshal.SystemDefaultCharSize) + { + case 1: + CPINFOEXA* pcpinfoexa = (CPINFOEXA*)thisPtr; + return pcpinfoexa->CodePageName; + case 2: + CPINFOEXW* pcpinfoexw = (CPINFOEXW*)thisPtr; + return pcpinfoexw->CodePageName; + default: throw new PlatformNotSupportedException(); + } + } + } + set + { + fixed (void* thisPtr = &this) + { + switch (Marshal.SystemDefaultCharSize) + { + case 1: + CPINFOEXA* pcpinfoexa = (CPINFOEXA*)thisPtr; + pcpinfoexa->CodePageName = value; + break; + case 2: + CPINFOEXW* pcpinfoexw = (CPINFOEXW*)thisPtr; + pcpinfoexw->CodePageName = value; + break; + default: throw new PlatformNotSupportedException(); + } + } + } + } + #endregion + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj index 1c606235..49f011c7 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj +++ b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj @@ -11,13 +11,20 @@ - + + All + - + All + + + + + From a8c9a2903d5f4c0b6777c1d9c4916e81d6480eea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 08:31:14 +0200 Subject: [PATCH 19/50] NUMBERFMT structures, winnls.h line 1141 --- .../NUMBERFMT.cs | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NUMBERFMT.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NUMBERFMT.cs b/src-native/THNETII.WinApi.Headers.WinNls/NUMBERFMT.cs new file mode 100644 index 00000000..b1af945f --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/NUMBERFMT.cs @@ -0,0 +1,89 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1115 + // + // Number format. + // + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1119 + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct NUMBERFMTA + { + /// + public int NumDigits; // number of decimal digits + /// + public int LeadingZero; // if leading zero in decimal fields + /// + public int Grouping; // group size left of decimal + /// + public LPSTR lpDecimalSep; // ptr to decimal separator string + /// + public LPSTR lpThousandSep; // ptr to thousand separator string + /// + public int NegativeOrder; // negative number ordering + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1127 + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct NUMBERFMTW + { + /// + public int NumDigits; // number of decimal digits + /// + public int LeadingZero; // if leading zero in decimal fields + /// + public int Grouping; // group size left of decimal + /// + public LPWSTR lpDecimalSep; // ptr to decimal separator string + /// + public LPWSTR lpThousandSep; // ptr to thousand separator string + /// + public int NegativeOrder; // negative number ordering + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1135 + /// + /// Contains information that defines the format of a number string. The function uses this information to customize a number string for a specified locale. + /// + /// + /// Microsoft Docs page: NUMBERFMTW structure + /// + /// + /// National Language Support Structures +#if NETSTANDARD1_3 + [StructLayout(LayoutKind.Sequential)] +#else + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] +#endif + public struct NUMBERFMT + { + /// + /// Number of fractional digits. This value is equivalent to the locale information specified by the value . + /// + public int NumDigits; // number of decimal digits + /// + /// A value indicating if leading zeros should be used in decimal fields. This value is equivalent to the locale information specified by the value . + /// + public int LeadingZero; // if leading zero in decimal fields + /// + /// Number of digits in each group of numbers to the left of the decimal separator specified by . Values in the range 0 through 9 and 32 are valid. The most significant grouping digit indicates the number of digits in the least significant group immediately to the left of the decimal separator. Each subsequent grouping digit indicates the next significant group of digits to the left of the previous group. If the last value supplied is not 0, the remaining groups repeat the last group. Typical examples of settings for this member are: 0 to group digits as in 123456789.00; 3 to group digits as in 123,456,789.00; and 32 to group digits as in 12,34,56,789.00. + /// You can use settings other than the typical settings, but they will not show up in the regional and language options portion of the Control Panel. Such settings are extremely uncommon and might have unexpected results. + /// + public int Grouping; // group size left of decimal + /// + /// Pointer to a null-terminated decimal separator string. + /// + public LPTSTR lpDecimalSep; // ptr to decimal separator string + /// + /// Pointer to a null-terminated thousand separator string. + /// + public LPTSTR lpThousandSep; // ptr to thousand separator string + /// + /// Negative number mode. This mode is equivalent to the locale information specified by the value . + /// + public int NegativeOrder; // negative number ordering + } +} From c29380f75bd278ede8f3b7a5ac3b5fb1e8a953cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 08:41:56 +0200 Subject: [PATCH 20/50] CURRENCYFMT structures, winnls.h line 1174 --- .../CURRENCYFMT.cs | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CURRENCYFMT.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CURRENCYFMT.cs b/src-native/THNETII.WinApi.Headers.WinNls/CURRENCYFMT.cs new file mode 100644 index 00000000..1aa8696c --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CURRENCYFMT.cs @@ -0,0 +1,105 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1144 + // + // Currency format. + // + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1148 + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CURRENCYFMTA + { + /// + public int NumDigits; // number of decimal digits + /// + public int LeadingZero; // if leading zero in decimal fields + /// + public int Grouping; // group size left of decimal + /// + public LPSTR lpDecimalSep; // ptr to decimal separator string + /// + public LPSTR lpThousandSep; // ptr to thousand separator string + /// + public int NegativeOrder; // negative currency ordering + /// + public int PositiveOrder; // positive currency ordering + /// + public LPSTR lpCurrencySymbol; // ptr to currency symbol string + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1158 + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] + public struct CURRENCYFMTW + { + /// + public int NumDigits; // number of decimal digits + /// + public int LeadingZero; // if leading zero in decimal fields + /// + public int Grouping; // group size left of decimal + /// + public LPWSTR lpDecimalSep; // ptr to decimal separator string + /// + public LPWSTR lpThousandSep; // ptr to thousand separator string + /// + public int NegativeOrder; // negative currency ordering + /// + public int PositiveOrder; // positive currency ordering + /// + public LPWSTR lpCurrencySymbol; // ptr to currency symbol string + } + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1168 + /// + /// Contains information that defines the format of a currency string. The function uses this information to customize a currency string for a specified locale. + /// + /// + /// Microsoft Docs page: CURRENCYFMTW structure + /// + /// + /// National Language Support Structures +#if NETSTANDARD1_3 + [StructLayout(LayoutKind.Sequential)] +#else + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] +#endif + public struct CURRENCYFMT + { + /// + /// Number of fractional digits. This number is equivalent to . + /// + public int NumDigits; // number of decimal digits + /// + /// Value indicating if leading zeros should be used in decimal fields. This value is equivalent to . + /// + public int LeadingZero; // if leading zero in decimal fields + /// + /// Number of digits in each group of numbers to the left of the decimal separator specified by . Values in the range 0 through 9 and 32 are valid. The most significant grouping digit indicates the number of digits in the least significant group immediately to the left of the decimal separator. Each subsequent grouping digit indicates the next significant group of digits to the left of the previous group. If the last value supplied is not 0, the remaining groups repeat the last group. Typical examples of settings for this member are: 0 to group digits as in 123456789.00; 3 to group digits as in 123,456,789.00; and 32 to group digits as in 12,34,56,789.00. + /// You can use settings other than the typical settings, but they will not show up in the regional and language options portion of the Control Panel. Such settings are extremely uncommon and might have unexpected results. + /// + public int Grouping; // group size left of decimal + /// + /// Pointer to a null-terminated decimal separator string. + /// + public LPTSTR lpDecimalSep; // ptr to decimal separator string + /// + /// Pointer to a null-terminated thousand separator string. + /// + public LPTSTR lpThousandSep; // ptr to thousand separator string + /// + /// Negative currency mode. This mode is equivalent to . + /// + public int NegativeOrder; // negative currency ordering + /// + /// Positive currency mode. This mode is equivalent to . + /// + public int PositiveOrder; // positive currency ordering + /// + /// Pointer to a null-terminated currency symbol string. + /// + public LPTSTR lpCurrencySymbol; // ptr to currency symbol string + } +} From 5e75ad6f1592883ac3da72680fd6f3b1b2a51e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 08:47:19 +0200 Subject: [PATCH 21/50] SYSNLS_FUNCTION enumeration, winnls.h line 1183 --- .../GlobalSuppressions.cs | 2 ++ .../SYSNLS_FUNCTION.cs | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/SYSNLS_FUNCTION.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs index d69967e6..3495ab0a 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs @@ -7,5 +7,7 @@ [assembly: SuppressMessage("Design", "CA1051: Do not declare visible instance fields")] +[assembly: SuppressMessage("Naming", + "CA1707: Identifiers should not contain underscores")] [assembly: SuppressMessage("Performance", "CA1815: Override equals and operator equals on value types")] diff --git a/src-native/THNETII.WinApi.Headers.WinNls/SYSNLS_FUNCTION.cs b/src-native/THNETII.WinApi.Headers.WinNls/SYSNLS_FUNCTION.cs new file mode 100644 index 00000000..913dca34 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/SYSNLS_FUNCTION.cs @@ -0,0 +1,26 @@ +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1176 + // + // NLS function capabilities + // + + /// + /// Specifies NLS function capabilities. + /// + /// + /// Microsoft Docs page: SYSNLS_FUNCTION enumeration + /// + /// + /// + /// + /// + /// National Language Support Enumeration Types + public enum SYSNLS_FUNCTION + { + /// + /// Value indicating comparison of two strings in the manner of the function or with the flag specified. + /// + COMPARE_STRING = 0x0001, + } +} From e6912ca1244f3e19d24008981575f2f2d8667bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 09:21:03 +0200 Subject: [PATCH 22/50] NLSVERSIONINFO structures, winnls.h line 1218 --- .../NLSVERSIONINFO.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFO.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFO.cs b/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFO.cs new file mode 100644 index 00000000..11898386 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFO.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Memory; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1186 + // + // NLS version structure. + // + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1206 + // + // Windows 7 and below had different sizes + // + + // This is to be deprecated, please use the NLSVERSIONINFOEX + // structure below in the future. The difference is that + // guidCustomversion is required to uniquely identify a sort + + /// + /// Deprecated. Contains version information about an NLS capability. + /// Starting with Windows 8, your app should use instead of . + /// + /// + /// See Remarks for . + /// Microsoft Docs page: NLSVERSIONINFO structure + /// + /// + /// + /// Handling Sorting in Your Applications + /// + /// + /// National Language Support Structures + [Obsolete("Starting with Windows 8, your app should use NLSVERSIONINFOEX instead of NLSVERSIONINFO.")] + [StructLayout(LayoutKind.Sequential)] + public struct NLSVERSIONINFO + { + public static readonly int SizeOf = SizeOf.Bytes; + + /// + /// Size, in bytes, of the structure. Use the value of on initialization. + /// + public int dwNLSVersionInfoSize; // 12 bytes + /// + /// NLS version. This value is used to track changes and additions to the set of code points that have the indicated capability for a particular locale. The value is locale-specific, and increments when the capability changes. For example, using the capability defined by the enumeration, the version changes if sorting weights are assigned to code points that previously had no weights defined for the locale. + /// + public int dwNLSVersion; + /// + /// Defined version. This value is used to track changes in the repertoire of Unicode code points. The value increments when the Unicode repertoire is extended, for example, if more characters are defined. + /// + [Obsolete("Deprecated, use dwNLSVersion instead")] + public int dwDefinedVersion; // Deprecated, use dwNLSVersion instead + } +} From 8b308dcfb51cfcd340f260e71e4548290c931349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 09:30:08 +0200 Subject: [PATCH 23/50] NLSVERSIONINFOEX structures, winnls.h line 1229 --- .../NLSVERSIONINFOEX.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFOEX.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFOEX.cs b/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFOEX.cs new file mode 100644 index 00000000..467e1295 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/NLSVERSIONINFOEX.cs @@ -0,0 +1,54 @@ +using System; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Memory; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1220 + // The combination of dwNLSVersion, and guidCustomVersion + // identify specific sort behavior, persist those to ensure identical + // behavior in the future. + + /// + /// Contains version information about an NLS capability. + /// + /// + /// The and members are completely independent. Although each member is defined for a single int, actually each is composed of a major version and a minor version. See Handling Sorting in Your Applications for more information. + /// Microsoft Docs page: NLSVERSIONINFOEX structure + /// + /// + /// Handling Sorting in Your Applications + /// + /// National Language Support Structures + [StructLayout(LayoutKind.Sequential)] + public struct NLSVERSIONINFOEX + { + public static readonly int SizeOf = SizeOf.Bytes; + + /// + /// Size, in bytes, of the structure. Use the value of on initialization. + /// + public int dwNLSVersionInfoSize; // sizeof(NLSVERSIONINFOEX) == 32 bytes + /// + /// NLS version. This value is used to track changes and additions to the set of code points that have the indicated capability for a particular locale. The value is locale-specific, and increments when the capability changes. For example, using the capability defined by the enumeration, the version changes if sorting weights are assigned to code points that previously had no weights defined for the locale. + /// + public int dwNLSVersion; + /// + /// Defined version. This value is used to track changes in the repertoire of Unicode code points. The value increments when the Unicode repertoire is extended, for example, if more characters are defined. + /// Starting with Windows 8: Deprecated. Use instead. + /// + [Obsolete("Starting with Windows 8: Deprecated, use dwNLSVersion instead")] + public int dwDefinedVersion; // Deprecated, use dwNLSVersion instead + /// + /// Identifier of the sort order used for the input locale for the represented version. For example, for a custom locale en-Mine that uses 0409 for a sort order identifier, this member contains 0409. If this member specifies a "real" sort, is set to an empty GUID. + /// Starting with Windows 8: Deprecated. Use instead. + /// + [Obsolete("Starting with Windows 8: Deprecated, use guidCustomVerison instead")] + public int dwEffectiveId; // Deprecated, use guidCustomVerison instead + /// + /// Unique GUID for the behavior of a custom sort used by the locale for the represented version. + /// + public Guid guidCustomVersion; // Explicit sort version + } +} From 9d314b0e674968770c0394c1b7af97f5e9455b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 09:47:03 +0200 Subject: [PATCH 24/50] Additional GEOID constants, winnls.h line 1250 --- src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 276b45f8..354a08bd 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -1539,5 +1539,8 @@ public static class WinNlsConstants public const int MUI_LIP_LANGUAGE = 0x04; public const int MUI_LANGUAGE_INSTALLED = 0x20; public const int MUI_LANGUAGE_LICENSED = 0x40; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1250 + public const int GEOID_NOT_AVAILABLE = -1; } } From cbff35a475689fdb17cd746df57638097403814e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 09:48:03 +0200 Subject: [PATCH 25/50] SYSGEOTYPE enumeration, winnls.h line 1281 --- .../SYSGEOTYPE.cs | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/SYSGEOTYPE.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOTYPE.cs b/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOTYPE.cs new file mode 100644 index 00000000..adff66a5 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOTYPE.cs @@ -0,0 +1,103 @@ +using System; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1256 + // + // GEO information types for clients to query + // + // Please use GetGeoInfoEx and query by country/region name instead of GEOID (eg: "US" instead of 244) + + /// + /// Defines the type of geographical location information requested in the or function. + /// + /// + /// Microsoft Docs page: SYSGEOTYPE enumeration + /// + /// + /// + /// National Language Support Enumeration Types + public enum SYSGEOTYPE + { + /// + /// The geographical location identifier (GEOID) of a nation. This value is stored in a long integer. + /// Starting with Windows 10, version 1709: This value is not supported for the function, and should not be used. + /// + [Obsolete("Starting with Windows 10, version 1709: This value is not supported for the GetGeoInfoEx function, and should not be used.")] + GEO_NATION = 0x0001, // DEPRECATED Not used by name API + /// + /// The latitude of the location. This value is stored in a floating-point number. + /// + GEO_LATITUDE = 0x0002, + /// + /// The longitude of the location. This value is stored in a floating-point number. + /// + GEO_LONGITUDE = 0x0003, + /// + /// The ISO 2-letter country/region code. This value is stored in a string. + /// + GEO_ISO2 = 0x0004, + /// + /// The ISO 3-letter country/region code. This value is stored in a string. + /// + GEO_ISO3 = 0x0005, + /// + /// The name for a string, compliant with RFC 4646 (starting with Windows Vista), that is derived from the parameters language and GeoId. + /// Starting with Windows 10, version 1709: This value is not supported for the function, and should not be used. + /// + [Obsolete("Starting with Windows 10, version 1709: This value is not supported for the GetGeoInfoEx function, and should not be used.")] + GEO_RFC1766 = 0x0006, // DEPRECATED and misleading, not used by name API + /// + /// A locale identifier derived using . + /// Starting with Windows 10, version 1709: This value is not supported for the function, and should not be used. + /// + [Obsolete("Starting with Windows 10, version 1709: This value is not supported for the GetGeoInfoEx function, and should not be used.")] + GEO_LCID = 0x0007, // DEPRECATED Not used by name API + /// + /// The friendly name of the nation, for example, Germany. This value is stored in a string. + /// + GEO_FRIENDLYNAME = 0x0008, + /// + /// The official name of the nation, for example, Federal Republic of Germany. This value is stored in a string. + /// + GEO_OFFICIALNAME = 0x0009, + /// + /// Not implemented. + /// + GEO_TIMEZONES = 0x000A, // Not implemented + /// + /// Not implemented. + /// + GEO_OFFICIALLANGUAGES = 0x000B, // Not implemented + /// + /// Starting with Windows 8: The ISO 3-digit country/region code. This value is stored in a string. + /// + GEO_ISO_UN_NUMBER = 0x000C, + /// + /// Starting with Windows 8: The geographical location identifier of the parent region of a country/region. This value is stored in a string. + /// + GEO_PARENT = 0x000D, + /// + /// Starting with Windows 10, version 1709: The dialing code to use with telephone numbers in the geographic location. For example, 1 for the United States. + /// + GEO_DIALINGCODE = 0x000E, + /// + /// Starting with Windows 10, version 1709: The three-letter code for the currency that the geographic location uses. For example, USD for United States dollars. + /// + GEO_CURRENCYCODE = 0x000F, // eg: USD + /// + /// Starting with Windows 10, version 1709: The symbol for the currency that the geographic location uses. For example, the dollar sign ($). + /// + GEO_CURRENCYSYMBOL = 0x0010, // eg: $ + /// + /// Starting with Windows 10, version 1709: The two-letter International Organization for Standardization (ISO) 3166-1 code or numeric United Nations (UN) Series M, Number 49 (M.49) code for the geographic region. + /// For information about two-letter ISO 3166-1 codes, see Country Codes - ISO 3166. For information about numeric UN M.49 codes, see Standard country or area codes for statistical use (M49). + /// + GEO_NAME = 0x0011, // Name, eg: US or 001 + /// + /// Starting with Windows 10, version 1709: The Windows geographical location identifiers (GEOID) for the region. This value is provided for backward compatibility. Do not use this value in new applications, but use instead. + /// + [Obsolete("Starting with Windows 10, version 1709: The Windows geographical location identifiers (GEOID) for the region. This value is provided for backward compatibility. Do not use this value in new applications, but use GEO_NAME instead.")] + GEO_ID = 0x0012 // DEPRECATED - For compatibility, please avoid + } +} From f0648a7f0a66aabab796f99ed26ef4211f24be9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 09:52:21 +0200 Subject: [PATCH 26/50] SYSGEOCLASS enumeration, winnls.h line 1291 --- .../SYSGEOCLASS.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/SYSGEOCLASS.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOCLASS.cs b/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOCLASS.cs new file mode 100644 index 00000000..8762b51d --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/SYSGEOCLASS.cs @@ -0,0 +1,30 @@ +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1283 + // + // More GEOCLASS defines will be listed here + // + + /// + /// Specifies the geographical location class. + /// + /// + /// Microsoft Docs page: SYSGEOCLASS enumeration + /// + /// National Language Support Enumeration Types + public enum SYSGEOCLASS + { + /// + /// Class for nation geographical location identifiers. + /// + GEOCLASS_NATION = 16, + /// + /// Class for region geographical location identifiers. + /// + GEOCLASS_REGION = 14, + /// + /// Starting with Windows 8: Class for all geographical location identifiers. + /// + GEOCLASS_ALL = 0 + } +} From 6b69007cb6012befd33cb11adc5e83ad226f1083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 10:20:04 +0200 Subject: [PATCH 27/50] NORM_FORM enumeration, winnls.h line 1306 --- .../NORM_FORM.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NORM_FORM.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NORM_FORM.cs b/src-native/THNETII.WinApi.Headers.WinNls/NORM_FORM.cs new file mode 100644 index 00000000..a48dfe66 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/NORM_FORM.cs @@ -0,0 +1,40 @@ +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1294 + // + // Normalization forms + // + + /// + /// Specifies the supported normalization forms. + /// + /// + /// Microsoft Docs page: NORM_FORM enumeration + /// + /// National Language Support Enumeration Types + public enum NORM_FORM + { + /// + /// Not supported. + /// + NormalizationOther = 0, // Not supported + /// + /// Unicode normalization form C, canonical composition. Transforms each decomposed grouping, consisting of a base character plus combining characters, to the canonical precomposed equivalent. For example, A + ¨ becomes Ä. + /// + NormalizationC = 0x1, // Each base plus combining characters to the canonical precomposed equivalent. + /// + /// Unicode normalization form D, canonical decomposition. Transforms each precomposed character to its canonical decomposed equivalent. For example, Ä becomes A + ¨. + /// + NormalizationD = 0x2, // Each precomposed character to its canonical decomposed equivalent. + /// + /// Unicode normalization form KC, compatibility composition. Transforms each base plus combining characters to the canonical precomposed equivalent and all compatibility characters to their equivalents. For example, the ligature becomes f + i; similarly, A + ¨ + + n becomes Ä + f + i + n. + /// + NormalizationKC = 0x5, // Each base plus combining characters to the canonical precomposed + // equivalents and all compatibility characters to their equivalents. + /// + /// Unicode normalization form KD, compatibility decomposition. Transforms each precomposed character to its canonical decomposed equivalent and all compatibility characters to their equivalents. For example, Ä + + n becomes A + ¨ + f + i + n. + /// + NormalizationKD = 0x6 // Each precomposed character to its canonical decomposed equivalent + // and all compatibility characters to their equivalents. + } +} From eb2253e27c50a7ecf6c17b16be91c6fb40738722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:12:02 +0200 Subject: [PATCH 28/50] Additional Win NLS constants, winnls.h line 1320 --- .../WinNlsConstants.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs index 354a08bd..06a69dae 100644 --- a/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs +++ b/src-native/THNETII.WinApi.Constants.WinNls/WinNlsConstants.cs @@ -1542,5 +1542,20 @@ public static class WinNlsConstants // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1250 public const int GEOID_NOT_AVAILABLE = -1; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1309 + // + // IDN (International Domain Name) Flags + // + public const int IDN_ALLOW_UNASSIGNED = 0x01; // Allow unassigned "query" behavior per RFC 3454 + public const int IDN_USE_STD3_ASCII_RULES = 0x02; // Enforce STD3 ASCII restrictions for legal characters + public const int IDN_EMAIL_ADDRESS = 0x04; // Enable EAI algorithmic fallback for email local parts behavior + public const int IDN_RAW_PUNYCODE = 0x08; // Disable validation and mapping of punycode. + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1317 + public const int VS_ALLOW_LATIN = 0x0001; // Allow Latin in test script even if not present in locale script + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1319 + public const int GSS_ALLOW_INHERITED_COMMON = 0x0001; // Output script ids for inherited and common character types if present } } From 4be82dbfe034bd374d2c22f3ba24a9e2f2aa491d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:13:11 +0200 Subject: [PATCH 29/50] LANGUAGEGROUP_ENUMPROC callback functions, winnls.h line 1393 --- .../LANGUAGEGROUP_ENUMPROC.cs | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs new file mode 100644 index 00000000..9cc541c6 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs @@ -0,0 +1,47 @@ +using System; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1328 + /// + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGUAGEGROUP_ENUMPROCA( + LGRPID lgrpid, + LPSTR arg2, + LPSTR arg3, + int arg4, + int arg5 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1341 + /// + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGUAGEGROUP_ENUMPROCW( + LGRPID lgrpid, + LPWSTR arg2, + LPWSTR arg3, + int arg4, + int arg5 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1392 + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGUAGEGROUP_ENUMPROC( + LGRPID lgrpid, + LPTSTR arg2, + LPTSTR arg3, + int arg4, + int arg5 + ); +} From 1c7a5cd904e76166c4ec6348e3aa42641298115d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:13:41 +0200 Subject: [PATCH 30/50] LANGGROUPLOCALE_ENUMPROC callback functions, winnls.h line 1395 --- .../LANGGROUPLOCALE_ENUMPROC.cs | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs new file mode 100644 index 00000000..8d7540ac --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs @@ -0,0 +1,56 @@ +using System; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1328 + /// + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGGROUPLOCALE_ENUMPROCA( + LGRPID lgrpid, + int lcid, + LPSTR Arg3, + int Arg4 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1343 + /// + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGGROUPLOCALE_ENUMPROCW( + LGRPID lgrpid, + int lcid, + LPWSTR Arg3, + int Arg4 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1394 + /// + /// An application-defined callback function that processes enumerated language group locale information provided by the function. The type defines a pointer to this callback function. + /// + /// Returns to continue enumeration or otherwise. + /// + /// An function can carry out any desired task. The application registers this function by passing its address to the function. + /// Microsoft Docs page: LANGGROUPLOCALE_ENUMPROCW callback function + /// + /// + /// + /// National Language Support + /// National Language Support Functions + [Obsolete("The Language Group concept is obsolete and no longer supported.")] + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LANGGROUPLOCALE_ENUMPROC( + LGRPID lgrpid, + int lcid, + LPTSTR Arg3, + int Arg4 + ); +} From 6056ca9497e357a2e97f597b723ad9d0a73b5f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:18:00 +0200 Subject: [PATCH 31/50] Fix Win NLS callback function parameters --- .../LANGGROUPLOCALE_ENUMPROC.cs | 6 +++--- .../THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs index 8d7540ac..2a6c5a53 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/LANGGROUPLOCALE_ENUMPROC.cs @@ -12,7 +12,7 @@ public delegate bool LANGGROUPLOCALE_ENUMPROCA( LGRPID lgrpid, int lcid, LPSTR Arg3, - int Arg4 + IntPtr Arg4 ); // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1343 @@ -24,7 +24,7 @@ public delegate bool LANGGROUPLOCALE_ENUMPROCW( LGRPID lgrpid, int lcid, LPWSTR Arg3, - int Arg4 + IntPtr Arg4 ); // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1394 @@ -51,6 +51,6 @@ public delegate bool LANGGROUPLOCALE_ENUMPROC( LGRPID lgrpid, int lcid, LPTSTR Arg3, - int Arg4 + IntPtr Arg4 ); } diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs index 9cc541c6..5893952f 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/LANGUAGEGROUP_ENUMPROC.cs @@ -13,7 +13,7 @@ public delegate bool LANGUAGEGROUP_ENUMPROCA( LPSTR arg2, LPSTR arg3, int arg4, - int arg5 + IntPtr arg5 ); // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1341 @@ -26,7 +26,7 @@ public delegate bool LANGUAGEGROUP_ENUMPROCW( LPWSTR arg2, LPWSTR arg3, int arg4, - int arg5 + IntPtr arg5 ); // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1392 @@ -42,6 +42,6 @@ public delegate bool LANGUAGEGROUP_ENUMPROC( LPTSTR arg2, LPTSTR arg3, int arg4, - int arg5 + IntPtr arg5 ); } From ffd8c7cbd9685bc71a2c0329b4dfd6cfd34311ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:25:44 +0200 Subject: [PATCH 32/50] UILANGUAGE_ENUMPROC callback functions, winnls.h line 1396 --- .../UILANGUAGE_ENUMPROC.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs new file mode 100644 index 00000000..6710683d --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs @@ -0,0 +1,51 @@ +using System; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1332 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool UILANGUAGE_ENUMPROCA( + LPSTR Arg1, + IntPtr Arg2 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1345 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool UILANGUAGE_ENUMPROCW( + LPWSTR Arg1, + IntPtr Arg2 + ); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1396 + /// + /// An application-defined callback function that processes enumerated user interface language information provided by the function. The type defines a pointer to this callback function. + /// + /// Returns to continue enumeration or otherwise. + /// + /// An function can carry out any task. The application registers this function by passing its address to the function. + /// + /// If was specified in the call to , the language strings passed to this function will be hexadecimal language + /// identifiers that do not include the leading 0x, and will be 4 characters in length. For example, en-US will + /// be passed as "0409" and en as "0009". + /// + /// Microsoft Docs page: LANGGROUPLOCALE_ENUMPROCW callback function + /// + /// + /// Multilingual User Interface + /// Multilingual User Interface Functions + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool UILANGUAGE_ENUMPROC( + LPTSTR Arg1, + IntPtr Arg2 + ); +} From 2d1ed44f529594cfbd0dc82e2e16deae0dcb28ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:56:51 +0200 Subject: [PATCH 33/50] GEO_ENUMNAMEPROC callback function, winnls.h line 1355 --- .../GEO_ENUMNAMEPROC.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMNAMEPROC.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMNAMEPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMNAMEPROC.cs new file mode 100644 index 00000000..8b12d7e3 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMNAMEPROC.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1353 + /// + /// An application-defined callback function that processes enumerated geographical location information provided by the function. The type defines a pointer to this callback function. + /// + /// Returns to continue enumeration or otherwise. + /// + /// An function can carry out any desired task, and can use the information passed to it in the data parameter for any desired purpose. The application registers this function by passing its address to the function. + /// For information about two-letter ISO 3166-1 codes, see Country Codes - ISO 3166. For information about numeric UN M.49 codes, see Standard country or area codes for statistical use (M49). + /// Microsoft Docs page: GEO_ENUMNAMEPROC callback function + /// + /// + /// National Language Support + /// National Language Support Functions + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool GEO_ENUMNAMEPROC( + LPWSTR Arg1, + IntPtr Arg2 + ); +} From aa209b253a321d5406416abd868822e51cb4b835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 11:56:59 +0200 Subject: [PATCH 34/50] Win NLS callback functions, winnls.h line 1420 --- .../CALINFO_ENUMPROC.cs | 26 +++++++++++++++++++ .../CALINFO_ENUMPROCEX.cs | 26 +++++++++++++++++++ .../CODEPAGE_ENUMPROC.cs | 26 +++++++++++++++++++ .../DATEFMT_ENUMPROC.cs | 26 +++++++++++++++++++ .../DATEFMT_ENUMPROCEX.cs | 26 +++++++++++++++++++ .../GEO_ENUMPROC.cs | 11 ++++++++ .../LOCALE_ENUMPROC.cs | 26 +++++++++++++++++++ .../TIMEFMT_ENUMPROC.cs | 26 +++++++++++++++++++ .../UILANGUAGE_ENUMPROC.cs | 2 +- 9 files changed, 194 insertions(+), 1 deletion(-) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROC.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROCEX.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CODEPAGE_ENUMPROC.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROC.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROCEX.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMPROC.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/LOCALE_ENUMPROC.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/TIMEFMT_ENUMPROC.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROC.cs new file mode 100644 index 00000000..e04687f8 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROC.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1337 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROCA(LPSTR Arg1); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1350 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROCW(LPWSTR Arg1); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1401 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROC(LPTSTR Arg1); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROCEX.cs b/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROCEX.cs new file mode 100644 index 00000000..7479cc83 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CALINFO_ENUMPROCEX.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1338 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROCEXA(LPSTR Arg1, CALID Arg2); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1351 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROCEXW(LPWSTR Arg1, CALID Arg2); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1402 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CALINFO_ENUMPROCEX(LPTSTR Arg1, CALID Arg2); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CODEPAGE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/CODEPAGE_ENUMPROC.cs new file mode 100644 index 00000000..baf7e983 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CODEPAGE_ENUMPROC.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1333 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CODEPAGE_ENUMPROCA(LPSTR Arg1); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1346 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CODEPAGE_ENUMPROCW(LPWSTR Arg1); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1397 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool CODEPAGE_ENUMPROC(LPTSTR Arg1); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROC.cs new file mode 100644 index 00000000..79aedf15 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROC.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1334 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROCA(LPSTR Arg1); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1347 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROCW(LPWSTR Arg1); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1398 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROC(LPTSTR Arg1); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROCEX.cs b/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROCEX.cs new file mode 100644 index 00000000..00d3f742 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/DATEFMT_ENUMPROCEX.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1335 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROCEXA(LPSTR Arg1, CALID Arg2); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1348 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROCEXW(LPWSTR Arg1, CALID Arg2); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1399 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool DATEFMT_ENUMPROCEX(LPTSTR Arg1, CALID Arg2); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMPROC.cs new file mode 100644 index 00000000..11ea2144 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/GEO_ENUMPROC.cs @@ -0,0 +1,11 @@ +using System; +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1352 + [Obsolete("DEPRECATED, use GEO_ENUMNAMEPROC instead")] + [UnmanagedFunctionPointer(CallingConvention.StdCall)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool GEO_ENUMPROC(int geoid); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/LOCALE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/LOCALE_ENUMPROC.cs new file mode 100644 index 00000000..11a269df --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/LOCALE_ENUMPROC.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1339 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LOCALE_ENUMPROCA(LPSTR Arg1); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1340 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LOCALE_ENUMPROCW(LPWSTR Arg1); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1403 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool LOCALE_ENUMPROC(LPTSTR Arg1); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/TIMEFMT_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/TIMEFMT_ENUMPROC.cs new file mode 100644 index 00000000..8e07f44a --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/TIMEFMT_ENUMPROC.cs @@ -0,0 +1,26 @@ +using System.Runtime.InteropServices; + +namespace THNETII.WinApi.Native.WinNls +{ + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1336 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool TIMEFMT_ENUMPROCA(LPSTR Arg1); + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1349 + /// + [UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool TIMEFMT_ENUMPROCW(LPWSTR Arg1); + + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1400 + [UnmanagedFunctionPointer(CallingConvention.StdCall +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public delegate bool TIMEFMT_ENUMPROC(LPTSTR Arg1); +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs b/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs index 6710683d..279f87f3 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/UILANGUAGE_ENUMPROC.cs @@ -33,7 +33,7 @@ IntPtr Arg2 /// identifiers that do not include the leading 0x, and will be 4 characters in length. For example, en-US will /// be passed as "0409" and en as "0009". /// - /// Microsoft Docs page: LANGGROUPLOCALE_ENUMPROCW callback function + /// Microsoft Docs page: UILANGUAGE_ENUMPROCW callback function /// /// /// Multilingual User Interface From aac37c0612dc1c4a70fc263244755d908ca5635a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 13:53:22 +0200 Subject: [PATCH 35/50] FILEMUIINFO structure, winnls.h line 1441 --- .../FILEMUIINFO.cs | 228 ++++++++++++++++++ .../GlobalSuppressions.cs | 4 + .../MUI_FILETYPE.cs | 14 ++ 3 files changed, 246 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/FILEMUIINFO.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/MUI_FILETYPE.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/FILEMUIINFO.cs b/src-native/THNETII.WinApi.Headers.WinNls/FILEMUIINFO.cs new file mode 100644 index 00000000..3193d401 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/FILEMUIINFO.cs @@ -0,0 +1,228 @@ +using System; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Memory; + +namespace THNETII.WinApi.Native.WinNls +{ + using static WinNlsConstants; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1422 + // + // Information about a MUI file, used as input/output in GetFileMUIInfo + // All offsets are relative to start of the structure. Offsets with value 0 mean empty field. + // + + /// + /// Contains information about a file, related to its use with MUI. Most of this data is stored in the resource configuration data for the particular file. When this structure is retrieved by , not all fields are necessarily filled in. The fields used depend on the flags that the application has passed to that function. + /// Your MUI applications can use the MUI macros to access this structure. + /// + /// + /// All offsets are from the base of the structure. An offset of 0 indicates that the data is not available. + /// Microsoft Docs page: FILEMUIINFO structure + /// + /// + /// Multilingual User Interface + /// Multilingual User Interface Macros + /// Multilingual User Interface Structures + [StructLayout(LayoutKind.Sequential)] + public unsafe struct FILEMUIINFO + { + public static readonly int SizeOf = SizeOf.Bytes; + + /// + /// Size of the structure, including the buffer, which can be extended past the 8 bytes declared. The minimum value allowed is . + /// + public int dwSize; // Size of the structure including buffer size [in] + /// + /// Version of the structure. The current version is . + /// + public int dwVersion; // Version of the structure [in] + /// + /// The file type. + /// + [MarshalAs(UnmanagedType.I4)] + public MUI_FILETYPE dwFileType; // Type of the file [out] + #region public fixed byte pChecksum[16]; + /// + /// Pointer to a 128-bit checksum for the file, if it is either an LN file or a language-specific resource file. + /// + internal fixed byte pChecksumField[16]; // Checksum of the file [out] + /// + /// A 128-bit checksum for the file, if it is either an LN file or a language-specific resource file. + /// + public Span pChecksum + { + get + { + fixed (byte* ptr = pServiceChecksumField) + return new Span(ptr, 16); + } + } + #endregion + #region public fixed byte pServiceChecksum[16]; + /// + /// Pointer to a 128-bit checksum for the file, used for servicing. + /// + internal fixed byte pServiceChecksumField[16]; // Checksum of the file [out] + /// + /// A 128-bit checksum for the file, used for servicing. + /// + public Span pServiceChecksum + { + get + { + fixed (byte* ptr = pServiceChecksumField) + return new Span(ptr, 16); + } + } + #endregion + /// + /// Offset, in bytes, from the beginning of the structure to the language name string for a language-specific resource file, or to the ultimate fallback language name string for an LN file. + /// + public int dwLanguageNameOffset; // Language name of the file [out] + /// + /// Size of the array for which the offset is indicated by dwTypeIDMainOffset. The size also corresponds to the number of strings in the multi-string array indicated by . + /// + public int dwTypeIDMainSize; // Number of TypeIDs in main module [out] + /// + /// Offset, in bytes, from the beginning of the structure to an array enumerating the resource types contained in the LN file. + /// + public int dwTypeIDMainOffset; // Array of TypeIDs (DWORD) in main module [out] + /// + /// Offset, in bytes, from the beginning of the structure to a series of null-terminated strings in a multi-string array enumerating the resource names contained in the LN file. + /// + public int dwTypeNameMainOffset; // Multistring array of TypeNames in main module [out] + /// + /// Size of the array with the offset indicated by . The size also corresponds to the number of strings in the series of strings indicated by . + /// + public int dwTypeIDMUISize; // Number of TypeIDs in MUI module [out] + /// + /// Offset, in bytes, from the beginning of the structure to an array enumerating the resource types contained in the LN file. + /// + public int dwTypeIDMUIOffset; // Array of TypeIDs (DWORD) in MUI module [out] + /// + /// Offset, in bytes, from the beginning of the structure to a multi-string array enumerating the resource names contained in the LN file. + /// + public int dwTypeNameMUIOffset; // Multistring array of TypeNames in MUI module [out] + #region public fixed byte abBuffer[8]; + internal fixed byte abBufferField[8]; // Buffer for extra data [in] (Size 4 is for padding) + /// + /// Remainder of the allocated memory for this structure. See the Remarks section for correct use of this array. + /// + public Span abBuffer + { + get + { + fixed (byte* ptr = abBufferField) + return new Span(ptr, 8); + } + } + #endregion + } + + /// + /// A pointer to a MUI File info structure. + /// + /// + [StructLayout(LayoutKind.Sequential)] + public struct PFILEMUIINFO : IPointer + { + private readonly IntPtr pointer; + + IntPtr IPointer.Pointer => pointer; + + internal ref FILEMUIINFO Value => ref pointer.AsRefStruct(); + + /// + public ref int Size => ref Value.dwSize; + /// + public ref int Version => ref Value.dwVersion; + /// + public ref MUI_FILETYPE FileType => ref Value.dwFileType; + /// + public Span Checksum => Value.pChecksum; + /// + public Span ServiceChecksum => Value.pServiceChecksum; + + /// + /// A pointer to the language name string for a language-specific resource file, or to the ultimate fallback language name string for an LN file. + /// + public LPCWSTR LanguageName + { + get + { + ref FILEMUIINFO value = ref Value; + int offset = value.dwLanguageNameOffset; + if (offset == 0) + return default; + return Pointer.Create(pointer + offset); + } + } + + /// + /// A span of resource type IDs contained in the LN file. + /// + public Span TypeIDMain + { + get + { + ref FILEMUIINFO value = ref Value; + int offset = value.dwTypeIDMainOffset; + int length = value.dwTypeIDMainSize; + if (offset == 0) + return Span.Empty; + return (pointer + offset).AsRefStructSpan(length); + } + } + + /// + /// A null-terminated multi-string pointer containing the resource names contained in the LN file. + /// + public LPCMWSTR TypeNameMain + { + get + { + ref FILEMUIINFO value = ref Value; + int offset = value.dwTypeNameMainOffset; + if (offset == 0) + return default; + return Pointer.Create(pointer + offset); + } + } + + /// + /// A span of the resource type IDs contained in the LN file. + /// + public Span TypeIDMUI + { + get + { + ref FILEMUIINFO value = ref Value; + int offset = value.dwTypeIDMUIOffset; + int length = value.dwTypeIDMUISize; + if (offset == 0) + return Span.Empty; + return (pointer + offset).AsRefStructSpan(length); + } + } + + /// + /// A null-terminated multi-string pointer containing the resource names contained in the LN file. + /// + public LPCMWSTR TypeNameMUI + { + get + { + ref FILEMUIINFO value = ref Value; + int offset = value.dwTypeNameMUIOffset; + if (offset == 0) + return default; + return Pointer.Create(pointer + offset); + } + } + + /// + public Span Buffer => Value.abBuffer; + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs index 3495ab0a..b8f21e03 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs @@ -9,5 +9,9 @@ "CA1051: Do not declare visible instance fields")] [assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] +[assembly: SuppressMessage("Naming", + "CA1712: Do not prefix enum values with type name")] [assembly: SuppressMessage("Performance", "CA1815: Override equals and operator equals on value types")] +[assembly: SuppressMessage("Style", + "IDE1006: Naming Styles")] diff --git a/src-native/THNETII.WinApi.Headers.WinNls/MUI_FILETYPE.cs b/src-native/THNETII.WinApi.Headers.WinNls/MUI_FILETYPE.cs new file mode 100644 index 00000000..eaf374e2 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/MUI_FILETYPE.cs @@ -0,0 +1,14 @@ +namespace THNETII.WinApi.Native.WinNls +{ + public enum MUI_FILETYPE : int + { + /// + /// The input file does not have resource configuration data. This file type is typical for older executable files. If this file type is specified, the other file types will not provide useful information. + /// + MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = WinNlsConstants.MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL, + /// The input file is an LN file. + MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = WinNlsConstants.MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN, + /// The input file is a language-specific resource file. + MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = WinNlsConstants.MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI, + } +} From 5bad49900f26784344503d447d8197c5e33e8f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 15:13:11 +0200 Subject: [PATCH 36/50] UTF-16 surrogate macros, winnls.h line 1463 --- .../WinNlsFunctions.cs | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs new file mode 100644 index 00000000..d93a12c6 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -0,0 +1,85 @@ +using System; + +namespace THNETII.WinApi.Native.WinNls +{ + using static WinNlsConstants; + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h + public static class WinNlsFunctions + { + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1448 + //////////////////////////////////////////////////////////////////////////// + // + // Macros + // + // Define all macros for the NLS component here. + // + //////////////////////////////////////////////////////////////////////////// + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1456 + // + // Macros to determine whether a character is a high or low surrogate, + // and whether two code points make up a surrogate pair (a high surrogate + // and a low surrogate). + // + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1461 + #region IS_HIGH_SURROGATE macro + /// + /// Determines if a character is a UTF-16 high surrogate code point, ranging from 0xd800 to 0xdbff, inclusive. + /// + /// Character to test. + /// + /// Microsoft Docs page: IS_HIGH_SURROGATE macro + /// + /// + /// + /// + /// National Language Support + /// National Language Support Macros + /// Surrogates and Supplementary Characters + [Obsolete(".NET applications should use the static methods on the System.Char type instead.")] + public static bool IS_HIGH_SURROGATE(char wch) => + (wch >= HIGH_SURROGATE_START) && (wch <= HIGH_SURROGATE_END); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1462 + #region IS_LOW_SURROGATE macro + /// + /// Determines if a character is a UTF-16 low surrogate code point, ranging from 0xdc00 to 0xdfff, inclusive. + /// + /// Character to test. + /// + /// Microsoft Docs page: IS_LOW_SURROGATE macro + /// + /// + /// + /// + /// National Language Support + /// National Language Support Macros + /// Surrogates and Supplementary Characters + [Obsolete(".NET applications should use the static methods on the System.Char type instead.")] + public static bool IS_LOW_SURROGATE(char wch) => + (((wch) >= LOW_SURROGATE_START) && ((wch) <= LOW_SURROGATE_END)); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1463 + #region IS_SURROGATE_PAIR macro + /// + /// Determines if the specified code units form a UTF-16 surrogate pair. + /// + /// UTF-16 code unit to test for a high surrogate value. The range for a high UTF-16 code unit is 0xd800 to 0xdbff, inclusive. + /// UTF-16 code unit to test for a low surrogate value. The range for a low UTF-16 code unit is 0xdc00 to 0xdfff, inclusive. + /// + /// For this macro to succeed, the value must be a high UTF-16 code unit, and the value must be a low UTF-16 code unit. + /// Microsoft Docs page: IS_SURROGATE_PAIR macro + /// + /// + /// + /// + /// National Language Support + /// National Language Support Macros + /// Surrogates and Supplementary Characters + [Obsolete(".NET applications should use the static methods on the System.Char type instead.")] + public static bool IS_SURROGATE_PAIR(char hs, char ls) => + (IS_HIGH_SURROGATE(hs) && IS_LOW_SURROGATE(ls)); + #endregion + } +} From ec3cf3c5a45ef31345871a1ec20469d453e6189f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 15:37:09 +0200 Subject: [PATCH 37/50] Win NLS Function prototypes: Initial Commit, winnls.h line 1504 --- .../THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index d93a12c6..acdd98ca 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -1,4 +1,6 @@ using System; +using System.Runtime.CompilerServices; +using THNETII.InteropServices.Memory; namespace THNETII.WinApi.Native.WinNls { @@ -81,5 +83,13 @@ public static bool IS_LOW_SURROGATE(char wch) => public static bool IS_SURROGATE_PAIR(char hs, char ls) => (IS_HIGH_SURROGATE(hs) && IS_LOW_SURROGATE(ls)); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1498 + //////////////////////////////////////////////////////////////////////////// + // + // Function Prototypes + // + // Only prototypes for the NLS APIs should go here. + // + //////////////////////////////////////////////////////////////////////////// } } From ff2046dd6211f1aaa5463beade54a8f9b364a7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 15:38:03 +0200 Subject: [PATCH 38/50] Code Page Dependent APIs: Initial Commit, winnls.h line 1510 --- .../THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index acdd98ca..f4395757 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -91,5 +91,13 @@ public static bool IS_SURROGATE_PAIR(char hs, char ls) => // Only prototypes for the NLS APIs should go here. // //////////////////////////////////////////////////////////////////////////// + + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1506 + // + // Code Page Dependent APIs. + // + // Applications should use Unicode (WCHAR / UTF-16 &/or UTF-8) + // + } } From 4c090c6f47c3475471d9562f001bf3ba545f5479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 15:47:42 +0200 Subject: [PATCH 39/50] IsValidCodePage function, winnls.h line 1516 --- .../GlobalSuppressions.cs | 2 + .../THNETII.WinApi.Headers.WinNls.csproj | 3 ++ .../WinNlsFunctions.cs | 40 ++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs index b8f21e03..7fc8c189 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs @@ -7,6 +7,8 @@ [assembly: SuppressMessage("Design", "CA1051: Do not declare visible instance fields")] +[assembly: SuppressMessage("Interoperability", + "CA1401: P/Invokes should not be visible")] [assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")] [assembly: SuppressMessage("Naming", diff --git a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj index 49f011c7..52b4db2f 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj +++ b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj @@ -23,6 +23,9 @@ + + All + diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index f4395757..f5ec7123 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -1,9 +1,13 @@ using System; -using System.Runtime.CompilerServices; -using THNETII.InteropServices.Memory; +using System.Runtime.InteropServices; + +#if NETSTANDARD1_3 +using EntryPointNotFoundException = System.Exception; +#endif namespace THNETII.WinApi.Native.WinNls { + using static NativeLibraryNames; using static WinNlsConstants; // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h @@ -99,5 +103,37 @@ public static bool IS_SURROGATE_PAIR(char hs, char ls) => // Applications should use Unicode (WCHAR / UTF-16 &/or UTF-8) // + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1512 + #region IsValidCodePage function + /// + /// Determines if a specified code page is valid. + /// + /// Code page identifier for the code page to check. + /// Returns if the code page is valid, or if the code page is invalid. + /// + /// A code page is considered valid only if it is installed on the operating system. Unicode is preferred. + /// Starting with Windows Vista, all code pages that can be installed are loaded by default. + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps | UWP apps] + /// Minimum supported server:Windows 2000 Server [desktop apps | UWP apps] + /// + /// + /// Microsoft Docs page: IsValidCodePage function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// + /// + /// National Language Support + /// National Language Support Functions + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool IsValidCodePage( + [In] int CodePage + ); + #endregion } } From 4c574a7cb37abcab4f92d1c2e0c5d2146c9b4fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sat, 18 Apr 2020 15:57:34 +0200 Subject: [PATCH 40/50] GetACP function, winnls.h line 1521 --- .../WinNlsFunctions.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index f5ec7123..ed0a40fc 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -135,5 +135,34 @@ public static extern bool IsValidCodePage( [In] int CodePage ); #endregion + #region GetACP function + /// + /// Retrieves the current Windows ANSI code page identifier for the operating system. + /// + /// The ANSI API functions, for example, the ANSI version of , implicitly use to translate text to or from Unicode. For the Multilingual User Interface (MUI) edition of Windows, the system ACP might not cover all code points in the user's selected logon language identifier. For compatibility with this edition, your application should avoid calls that depend on either implicitly or explicitly, as this function can cause some locales to display text as question marks. Instead, the application should use the Unicode API functions directly, for example, the Unicode version of . + /// + /// + /// Returns the current Windows ANSI code page (ACP) identifier for the operating system. See Code Page Identifiers for a list of identifiers for Windows ANSI code pages and other code pages. + /// + /// The ANSI code pages can be different on different computers, or can be changed for a single computer, leading to data corruption. For the most consistent results, applications should use UTF-8 or UTF-16 when possible. + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps | UWP apps] + /// Minimum supported server:Windows 2000 Server [desktop apps | UWP apps] + /// + /// + /// Microsoft Docs page: GetACP function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// Code Page Identifiers + /// + /// + /// National Language Support + /// National Language Support Functions + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] + public static extern int GetACP(); + #endregion } } From 9da2f8968acd8688913feee955dbe6d89d7ae361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 11:10:09 +0200 Subject: [PATCH 41/50] Unit tests for WinNls functions --- .../THNETII.WinApi.Native.Test.csproj | 17 +++++++-- .../WinNls.Test/GetACP.cs | 37 +++++++++++++++++++ .../WinNls.Test/IsValidCodePage.cs | 27 ++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/GetACP.cs create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/IsValidCodePage.cs diff --git a/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj b/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj index e273e8f8..4bd1121d 100644 --- a/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj +++ b/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj @@ -1,4 +1,4 @@ - + @@ -18,8 +18,9 @@ - - + + + @@ -28,9 +29,19 @@ + + + + + + + + + + diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetACP.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetACP.cs new file mode 100644 index 00000000..edd08e23 --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetACP.cs @@ -0,0 +1,37 @@ +using System.Text; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class GetACP + { + [FactWindowsOS] + public static void ReturnsNonZeroCodePage() + { + int codepage = GetACP(); + + Assert.InRange(codepage, 1, ushort.MaxValue); + } + + [FactWindowsOS] + public static void ReturnedCodePageIsValid() + { + int codepage = GetACP(); + Assert.True(IsValidCodePage(codepage)); + } + + [FactWindowsOS] + public static void CanCreateEncodingFromReturnedCodePage() + { + int codepage = GetACP(); + + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + var encoding = Encoding.GetEncoding(codepage); + + Assert.NotNull(encoding); + } + } +} diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/IsValidCodePage.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/IsValidCodePage.cs new file mode 100644 index 00000000..3a9b81d3 --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/IsValidCodePage.cs @@ -0,0 +1,27 @@ +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class IsValidCodePage + { + [TheoryWindowsOS] + [InlineData(437)] // IBM437 OEM United States + [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) + [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) + [InlineData(1252)] // windows-1252 ANSI Latin 1; Western European (Windows) + [InlineData(20127)] // us-ascii US-ASCII (7-bit) + [InlineData(28591)] // iso-8859-1 ISO 8859-1 Latin 1; Western European (ISO) + [InlineData(28605)] // iso-8859-15 ISO 8859-15 Latin 9 + [InlineData(65001)] // utf-8 Unicode (UTF-8) + public static void ReturnsTrueForCodePage(int codepage) => + Assert.True(IsValidCodePage(codepage)); + + [TheoryWindowsOS] + [InlineData(0)] // Non existant + [InlineData(ushort.MaxValue + 100)] // Max Code Page is ushort.MaxValue + public static void ReturnsFalseForInvalidCodePage(int codepage) => + Assert.False(IsValidCodePage(codepage)); + } +} From b836467e4f807656695643a15101395ff706c73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 11:36:57 +0200 Subject: [PATCH 42/50] GetOEMCP function, winnls.h line 1532 --- .../GlobalSuppressions.cs | 2 + .../WinNlsFunctions.cs | 27 ++++++++++++++ .../WinNls.Test/GetOEMCP.cs | 37 +++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/GetOEMCP.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs index 7fc8c189..eb508c93 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/GlobalSuppressions.cs @@ -17,3 +17,5 @@ "CA1815: Override equals and operator equals on value types")] [assembly: SuppressMessage("Style", "IDE1006: Naming Styles")] +[assembly: SuppressMessage("Usage", + "PC003: Native API not available in UWP")] diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index ed0a40fc..76720a7b 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -135,6 +135,7 @@ public static extern bool IsValidCodePage( [In] int CodePage ); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1518 #region GetACP function /// /// Retrieves the current Windows ANSI code page identifier for the operating system. @@ -164,5 +165,31 @@ [In] int CodePage [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] public static extern int GetACP(); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1529 + #region GetOEMCP function + /// + /// Returns the current original equipment manufacturer (OEM) code page identifier for the operating system. + /// The ANSI code pages can be different on different computers, or can be changed for a single computer, leading to data corruption. For the most consistent results, applications should use Unicode, such as UTF-8 or UTF-16, instead of a specific code page. + /// + /// Returns the current OEM code page identifier for the operating system. + /// + /// See Code Page Identifiers for a list of OEM and other code pages. + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps only] + /// Minimum supported server:Windows 2000 Server [desktop apps only] + /// + /// + /// Microsoft Docs page: GetOEMCP function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// National Language Support + /// National Language Support Functions + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] + public static extern int GetOEMCP(); + #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetOEMCP.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetOEMCP.cs new file mode 100644 index 00000000..ec0772ea --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetOEMCP.cs @@ -0,0 +1,37 @@ +using System.Text; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class GetOEMCP + { + [FactWindowsOS] + public static void ReturnsNonZeroCodePage() + { + int codepage = GetOEMCP(); + + Assert.InRange(codepage, 1, ushort.MaxValue); + } + + [FactWindowsOS] + public static void ReturnedCodePageIsValid() + { + int codepage = GetOEMCP(); + Assert.True(IsValidCodePage(codepage)); + } + + [FactWindowsOS] + public static void CanCreateEncodingFromReturnedCodePage() + { + int codepage = GetOEMCP(); + + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + var encoding = Encoding.GetEncoding(codepage); + + Assert.NotNull(encoding); + } + } +} From c333796b66062fd8f066e889a1754a977b9c799e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 12:08:28 +0200 Subject: [PATCH 43/50] GetCPInfo function, winnls.h line 1546 --- .../THNETII.WinApi.Headers.WinNls.csproj | 3 ++ .../WinNlsFunctions.cs | 47 +++++++++++++++++++ .../WinNls.Test/GetCPInfo.cs | 40 ++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj index 52b4db2f..7a1bdac2 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj +++ b/src-native/THNETII.WinApi.Headers.WinNls/THNETII.WinApi.Headers.WinNls.csproj @@ -14,6 +14,9 @@ All + + All + diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index 76720a7b..60364679 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -1,6 +1,8 @@ using System; using System.Runtime.InteropServices; +using THNETII.WinApi.Native.WinError; + #if NETSTANDARD1_3 using EntryPointNotFoundException = System.Exception; #endif @@ -8,6 +10,7 @@ namespace THNETII.WinApi.Native.WinNls { using static NativeLibraryNames; + using static WinErrorConstants; using static WinNlsConstants; // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h @@ -191,5 +194,49 @@ [In] int CodePage [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi)] public static extern int GetOEMCP(); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1540 + #region GetCPInfo function + /// + /// Retrieves information about any valid installed or available code page. + /// To obtain additional information about valid installed or available code pages, the application should use . + /// + /// Identifier for the code page for which to retrieve information. For details, see the CodePage parameter of . + /// A structure that receives information about the code page. See the Remarks section. + /// + /// Returns if successful, or otherwise. To get extended error information, the application can call , which can return one of the following error codes: + /// + /// Any of the parameter values was invalid. + /// + /// + /// + /// See Remarks for . + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps | UWP apps] + /// Minimum supported server:Windows 2000 Server [desktop apps | UWP apps] + /// + /// + /// Microsoft Docs page: GetCPInfo function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// Code Page Identifiers + /// + /// + /// + /// + /// National Language Support + /// National Language Support Functions + /// + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accuratedly and may be unreliable on many machines.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetCPInfo( + [In] int CodePage, + out CPINFO lpCPInfo + ); + #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs new file mode 100644 index 00000000..0f2031b5 --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs @@ -0,0 +1,40 @@ +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; +using System.Text; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class GetCPInfo + { + [TheoryWindowsOS] + [InlineData(437)] // IBM437 OEM United States + [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) + [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) + [InlineData(1252)] // windows-1252 ANSI Latin 1; Western European (Windows) + [InlineData(20127)] // us-ascii US-ASCII (7-bit) + [InlineData(28591)] // iso-8859-1 ISO 8859-1 Latin 1; Western European (ISO) + [InlineData(28605)] // iso-8859-15 ISO 8859-15 Latin 9 + [InlineData(65001)] // utf-8 Unicode (UTF-8) + [Obsolete("Deprecated Win API")] + public static void ReturnsTrueForCodePage(int codepage) + { + bool success = GetCPInfo(codepage, out var cpinfo); + + if (!success) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.True(success); + + _ = cpinfo.MaxCharSize; + foreach (ref readonly byte leadByte in cpinfo.LeadByte) + _ = leadByte; + foreach (ref readonly byte defaultByte in cpinfo.DefaultChar) + _ = defaultByte; + } + } +} From 86374ff33045aa4ebcd2c2e3392d578b20b109ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 12:37:30 +0200 Subject: [PATCH 44/50] GetCPInfoEx functions, winnls.h line 1568 --- .../WinNlsFunctions.cs | 79 +++++++++++++ .../THNETII.WinApi.Native.Test.csproj | 3 + .../WinNls.Test/GetCPInfo.cs | 5 + .../WinNls.Test/GetCPInfoEx.cs | 110 ++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfoEx.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index 60364679..c68643ae 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -238,5 +238,84 @@ public static extern bool GetCPInfo( out CPINFO lpCPInfo ); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1548 + #region GetCPInfoExA function + /// + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accuratedly and may be unreliable on many machines.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetCPInfoExA( + [In] int CodePage, + [In] int dwFlags, + out CPINFOEXA lpCPInfoEx + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1556 + #region GetCPInfoExW function + /// + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accuratedly and may be unreliable on many machines.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetCPInfoExW( + [In] int CodePage, + [In] int dwFlags, + out CPINFOEXW lpCPInfoEx + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1564 + #region GetCPInfoEx function + /// + /// Retrieves information about any valid installed or available code page. + /// + /// + /// Identifier for the code page for which to retrieve information. The application can specify the code page identifier for any installed or available code page, or one of the following predefined values. See Code Page Identifiers for a list of identifiers for ANSI and other code pages. + /// + /// ValueMeaning + /// Use the system default Windows ANSI code page. + /// Use the system default Macintosh code page. + /// Use the system default OEM code page. + /// Use the current thread's ANSI code page. + /// + /// + /// Reserved; must be 0 (zero). + /// A structure that receives information about the code page. + /// + /// Returns if successful, or otherwise. To get extended error information, the application can call , which can return one of the following error codes: + /// + /// Any of the parameter values was invalid. + /// + /// + /// + /// The information retrieved in the structure is not always useful for all code pages. To determine buffer sizes, for example, the application should call or to request an accurate buffer size. If settings indicate that a lead byte exists, the conversion function does not necessarily handle lead bytes differently, for example, in the case of a missing or illegal trail byte. + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps | UWP apps] + /// Minimum supported server:Windows 2000 Server [desktop apps | UWP apps] + /// + /// + /// Microsoft Docs page: GetCPInfoExW function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// + /// + /// + /// National Language Support + /// National Language Support Functions + [Obsolete("Use Unicode. The information in this structure cannot represent all encodings accuratedly and may be unreliable on many machines.")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true +#if !NETSTANDARD1_3 + , CharSet = CharSet.Auto +#endif + )] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool GetCPInfoEx( + [In] int CodePage, + [In] int dwFlags, + out CPINFOEX lpCPInfoEx + ); + #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj b/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj index 4bd1121d..4a3c2f6c 100644 --- a/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj +++ b/test/THNETII.WinApi.Native.Test/THNETII.WinApi.Native.Test.csproj @@ -23,6 +23,9 @@ + + All + diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs index 0f2031b5..a0145936 100644 --- a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfo.cs @@ -7,11 +7,16 @@ namespace THNETII.WinApi.Native.WinNls.Test { + using static WinNlsConstants; using static WinNlsFunctions; public static class GetCPInfo { [TheoryWindowsOS] + [InlineData(CP_ACP)] + [InlineData(CP_MACCP)] + [InlineData(CP_OEMCP)] + [InlineData(CP_THREAD_ACP)] [InlineData(437)] // IBM437 OEM United States [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfoEx.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfoEx.cs new file mode 100644 index 00000000..614fcf64 --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/GetCPInfoEx.cs @@ -0,0 +1,110 @@ +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsConstants; + using static WinNlsFunctions; + + public static class GetCPInfoEx + { + [TheoryWindowsOS] + [InlineData(CP_ACP)] + [InlineData(CP_MACCP)] + [InlineData(CP_OEMCP)] + [InlineData(CP_THREAD_ACP)] + [InlineData(437)] // IBM437 OEM United States + [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) + [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) + [InlineData(1252)] // windows-1252 ANSI Latin 1; Western European (Windows) + [InlineData(20127)] // us-ascii US-ASCII (7-bit) + [InlineData(28591)] // iso-8859-1 ISO 8859-1 Latin 1; Western European (ISO) + [InlineData(28605)] // iso-8859-15 ISO 8859-15 Latin 9 + [InlineData(65001)] // utf-8 Unicode (UTF-8) + [Obsolete("Deprecated Win API")] + public static void ReturnsTrueForCodePageAnsi(int codepage) + { + bool success = GetCPInfoExA(codepage, default, out var cpinfo); + + if (!success) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.True(success); + + _ = cpinfo.MaxCharSize; + foreach (ref readonly byte defaultByte in cpinfo.DefaultChar) + _ = defaultByte; + foreach (ref readonly byte leadByte in cpinfo.LeadByte) + _ = leadByte; + _ = cpinfo.UnicodeDefaultChar; + _ = cpinfo.CodePageName; + } + + [TheoryWindowsOS] + [InlineData(CP_ACP)] + [InlineData(CP_MACCP)] + [InlineData(CP_OEMCP)] + [InlineData(CP_THREAD_ACP)] + [InlineData(437)] // IBM437 OEM United States + [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) + [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) + [InlineData(1252)] // windows-1252 ANSI Latin 1; Western European (Windows) + [InlineData(20127)] // us-ascii US-ASCII (7-bit) + [InlineData(28591)] // iso-8859-1 ISO 8859-1 Latin 1; Western European (ISO) + [InlineData(28605)] // iso-8859-15 ISO 8859-15 Latin 9 + [InlineData(65001)] // utf-8 Unicode (UTF-8) + [Obsolete("Deprecated Win API")] + public static void ReturnsTrueForCodePageUnicode(int codepage) + { + bool success = GetCPInfoExW(codepage, default, out var cpinfo); + + if (!success) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.True(success); + + _ = cpinfo.MaxCharSize; + foreach (ref readonly byte defaultByte in cpinfo.DefaultChar) + _ = defaultByte; + foreach (ref readonly byte leadByte in cpinfo.LeadByte) + _ = leadByte; + _ = cpinfo.UnicodeDefaultChar; + _ = cpinfo.CodePageName; + } + + [TheoryWindowsOS] + [InlineData(CP_ACP)] + [InlineData(CP_MACCP)] + [InlineData(CP_OEMCP)] + [InlineData(CP_THREAD_ACP)] + [InlineData(437)] // IBM437 OEM United States + [InlineData(850)] // ibm850 OEM Multilingual Latin 1; Western European (DOS) + [InlineData(1250)] // windows-1250 ANSI Central European; Central European (Windows) + [InlineData(1252)] // windows-1252 ANSI Latin 1; Western European (Windows) + [InlineData(20127)] // us-ascii US-ASCII (7-bit) + [InlineData(28591)] // iso-8859-1 ISO 8859-1 Latin 1; Western European (ISO) + [InlineData(28605)] // iso-8859-15 ISO 8859-15 Latin 9 + [InlineData(65001)] // utf-8 Unicode (UTF-8) + [Obsolete("Deprecated Win API")] + public static void ReturnsTrueForCodePageAuto(int codepage) + { + bool success = GetCPInfoEx(codepage, default, out var cpinfo); + + if (!success) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.True(success); + + _ = cpinfo.MaxCharSize; + foreach (ref readonly byte defaultByte in cpinfo.DefaultChar) + _ = defaultByte; + foreach (ref readonly byte leadByte in cpinfo.LeadByte) + _ = leadByte; + _ = cpinfo.UnicodeDefaultChar; + _ = cpinfo.CodePageName; + } + } +} From d202ee97cfbc1cf21c76a7acfcd1949764822b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 12:38:42 +0200 Subject: [PATCH 45/50] Code Page Dependent APIs: Completed APIs, winnls.h line 1570 From b445ab872b12a4bb385c76c07708f81402736c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 12:51:40 +0200 Subject: [PATCH 46/50] Locale Dependent APIs: Initial Commit, winnls.h line 1578 --- src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index c68643ae..329c7ec0 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -317,5 +317,9 @@ public static extern bool GetCPInfoEx( out CPINFOEX lpCPInfoEx ); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1576 + // + // Locale Dependent APIs. + // } } From b64aba2df64c1d1a85ed28f26a398b9b3afb0411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 14:51:56 +0200 Subject: [PATCH 47/50] CompareString functions, winnls.h line 1622 --- .../THNETII.WinApi.Sample.Native/main.c | 4 +- .../CSTR_FLAGS.cs | 45 ++++ .../CSTR_RESULT.cs | 15 ++ .../WinNlsFunctions.cs | 225 ++++++++++++++++++ .../WinNls.Test/CompareString.cs | 121 ++++++++++ 5 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/CSTR_RESULT.cs create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs diff --git a/src-native-c/THNETII.WinApi.Sample.Native/main.c b/src-native-c/THNETII.WinApi.Sample.Native/main.c index 3897b7be..2a2f6d50 100644 --- a/src-native-c/THNETII.WinApi.Sample.Native/main.c +++ b/src-native-c/THNETII.WinApi.Sample.Native/main.c @@ -4,9 +4,9 @@ int main(int argc, char* argv[]) { DWORD instance; const int size = sizeof(instance); - const int value = NULL; + const int value = LINGUISTIC_IGNORECASE; - const void* ptr = ConvertDefaultLocale; + const void* ptr = CompareStringW; return EXIT_SUCCESS; } diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs b/src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs new file mode 100644 index 00000000..4baf4105 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs @@ -0,0 +1,45 @@ +using System; + +namespace THNETII.WinApi.Native.WinNls +{ + [Flags] + public enum CSTR_FLAGS : int + { + /// + /// Ignore case. For many scripts (notably Latin scripts), coincides with . + /// ignores any tertiary distinction, whether it is actually linguistic case or not. For example, in Arabic and Indic scripts, this distinguishes alternate forms of a character, but the differences do not correspond to linguistic case. causes the function to ignore only actual linguistic casing, instead of ignoring the third sorting weight. + /// With this flag set, the function ignores the distinction between the wide and narrow forms of the CJK compatibility characters. + /// + NORM_IGNORECASE = WinNlsConstants.NORM_IGNORECASE, + /// + /// Ignore nonspacing characters. For many scripts (notably Latin scripts), coincides with . + /// ignores any secondary distinction, whether it is a diacritic or not. Scripts for Korean, Japanese, Chinese, and Indic languages, among others, use this distinction for purposes other than diacritics. causes the function to ignore only actual diacritics, instead of ignoring the second sorting weight. + /// only has an effect for locales in which accented characters are sorted in a second pass from main characters. Normally all characters in the string are first compared without regard to accents and, if the strings are equal, a second pass over the strings is performed to compare accents. This flag causes the second pass to not be performed. For locales that sort accented characters in the first pass, this flag has no effect. + /// + NORM_IGNORENONSPACE = WinNlsConstants.NORM_IGNORENONSPACE, + /// Ignore symbols and punctuation. + NORM_IGNORESYMBOLS = WinNlsConstants.NORM_IGNORESYMBOLS, + + /// + /// Ignore case, as linguistically appropriate. + /// + LINGUISTIC_IGNORECASE = WinNlsConstants.LINGUISTIC_IGNORECASE, + /// + /// Ignore nonspacing characters, as linguistically appropriate. + /// This flag does not always produce predictable results when used with decomposed characters, that is, characters in which a base character and one or more nonspacing characters each have distinct code point values. + /// + LINGUISTIC_IGNOREDIACRITIC = WinNlsConstants.LINGUISTIC_IGNOREDIACRITIC, + + /// Do not differentiate between hiragana and katakana characters. Corresponding hiragana and katakana characters compare as equal. + NORM_IGNOREKANATYPE = WinNlsConstants.NORM_IGNOREKANATYPE, + /// Ignore the difference between half-width and full-width characters, for example, C a t == cat. The full-width form is a formatting distinction used in Chinese and Japanese scripts. + NORM_IGNOREWIDTH = WinNlsConstants.NORM_IGNOREWIDTH, + /// Use the default linguistic rules for casing, instead of file system rules. Note that most scenarios for use this flag. This flag does not have to be used when your application calls . + NORM_LINGUISTIC_CASING = WinNlsConstants.NORM_LINGUISTIC_CASING, + + /// Treat punctuation the same as symbols. + SORT_STRINGSORT = WinNlsConstants.SORT_STRINGSORT, + /// Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10". + SORT_DIGITSASNUMBERS = WinNlsConstants.SORT_DIGITSASNUMBERS, + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CSTR_RESULT.cs b/src-native/THNETII.WinApi.Headers.WinNls/CSTR_RESULT.cs new file mode 100644 index 00000000..60e7a3e3 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/CSTR_RESULT.cs @@ -0,0 +1,15 @@ +namespace THNETII.WinApi.Native.WinNls +{ + /// + /// Compare String Return Values. + /// + public enum CSTR_RESULT : int + { + /// string 1 less than string 2 + CSTR_LESS_THAN = WinNlsConstants.CSTR_LESS_THAN, + /// string 1 equal to string 2 + CSTR_EQUAL = WinNlsConstants.CSTR_EQUAL, + /// string 1 greater than string 2 + CSTR_GREATER_THAN = WinNlsConstants.CSTR_GREATER_THAN, + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index 329c7ec0..3949ba40 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -1,7 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using THNETII.WinApi.Native.WinError; +using THNETII.InteropServices.Memory; #if NETSTANDARD1_3 using EntryPointNotFoundException = System.Exception; @@ -321,5 +323,228 @@ out CPINFOEX lpCPInfoEx // // Locale Dependent APIs. // + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1580 + #region CompareStringA function + /// + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + public static CSTR_RESULT CompareStringA( + int Locale, + CSTR_FLAGS dwCmpFlags, + string lpString1, + string lpString2 + ) => + CompareStringA( + Locale, + dwCmpFlags, + lpString1, + lpString1?.Length ?? 0, + lpString2, + lpString2?.Length ?? 0 + ); + + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", + Justification = nameof(CharSet.Ansi))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern CSTR_RESULT CompareStringA( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] string lpString1, + [In] int cchCount1, + [In] string lpString2, + [In] int cchCount2 + ); + + /// + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", + Justification = nameof(CharSet.Ansi))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Ansi)] + [return: MarshalAs(UnmanagedType.I4)] + public static extern CSTR_RESULT CompareStringA( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] LPSTR lpString1, + [In] int cchCount1, + [In] LPSTR lpString2, + [In] int cchCount2 + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\stringapiset.h, line 66 + #region CompareStringW function + /// + public static CSTR_RESULT CompareStringW( + int Locale, + CSTR_FLAGS dwCmpFlags, + string lpString1, + string lpString2 + ) => + CompareStringW( + Locale, + dwCmpFlags, + lpString1, + lpString1?.Length ?? 0, + lpString2, + lpString2?.Length ?? 0 + ); + + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern CSTR_RESULT CompareStringW( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] string lpString1, + [In] int cchCount1, + [In] string lpString2, + [In] int cchCount2 + ); + + /// + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] + [return: MarshalAs(UnmanagedType.I4)] + public static extern CSTR_RESULT CompareStringW( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] LPWSTR lpString1, + [In] int cchCount1, + [In] LPWSTR lpString2, + [In] int cchCount2 + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1592 + #region CompareString function + /// + /// Compares two character strings, for a locale specified by identifier. + /// Using incorrectly can compromise the security of your application. Strings that are not compared correctly can produce invalid input. For example, the function can raise security issues when used for a non-linguistic comparison, because two strings that are distinct in their binary representation can be linguistically equivalent. The application should test strings for validity before using them, and should provide error handlers. For more information, see Security Considerations: International Features. + /// For compatibility with Unicode, your applications should prefer or the Unicode version of . Another reason for preferring is that Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales, for interoperability reasons. Any application that will be run only on Windows Vista and later should use . + /// + /// + /// Locale identifier of the locale used for the comparison. You can use the macro to create a locale identifier or use one of the following predefined values. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Flags that indicate how the function compares the two strings. By default, these flags are not set. This parameter can be set to 0 (or ) to obtain the default behavior. + /// + /// The first string to compare. + /// The application can supply a negative value for the length parameter if the string is null-terminated. In this case, the function determines the length automatically. + /// + /// + /// The second string to compare. + /// The application can supply a negative value for the length parameter if the string is null-terminated. In this case, the function determines the length automatically. + /// + /// Returns the values described for . + /// + /// See Remarks for . + /// If your application is calling the ANSI version of , the function converts parameters via the default code page of the supplied locale. Thus, an application can never use to handle UTF-8 text. + /// Normally, for case-insensitive comparisons, maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azerbaijani. The flag overrides this behavior for Turkish or Azerbaijani. If this flag is specified in conjunction with Turkish or Azerbaijani, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130). + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps | UWP apps] + /// Minimum supported server:Windows 2000 Server [desktop apps | UWP apps] + /// + /// + /// Microsoft Docs page: CompareString function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + public static CSTR_RESULT CompareString( + int Locale, + CSTR_FLAGS dwCmpFlags, + string lpString1, + string lpString2 + ) => + CompareString( + Locale, + dwCmpFlags, + lpString1, + lpString1?.Length ?? 0, + lpString2, + lpString2?.Length ?? 0 + ); + + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] +#if !NETSTANDARD1_3 + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", + Justification = nameof(CharSet.Auto))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto)] + [return: MarshalAs(UnmanagedType.I4)] + private static extern +#else + private static +#endif + CSTR_RESULT CompareString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] string lpString1, + [In] int cchCount1, + [In] string lpString2, + [In] int cchCount2 + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CompareStringA(Locale, dwCmpFlags, lpString1, cchCount1, + lpString2, cchCount2), + 2 => CompareStringW(Locale, dwCmpFlags, lpString1, cchCount1, + lpString2, cchCount2), + _ => throw new PlatformNotSupportedException() + }; +#endif + + /// + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] +#if !NETSTANDARD1_3 + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", + Justification = nameof(CharSet.Auto))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto)] + [return: MarshalAs(UnmanagedType.I4)] + public static extern +#else + public static +#endif + CSTR_RESULT CompareString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + CSTR_FLAGS dwCmpFlags, + [In] LPTSTR lpString1, + [In] int cchCount1, + [In] LPTSTR lpString2, + [In] int cchCount2 + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => CompareStringA(Locale, dwCmpFlags, + Pointer.Create(lpString1.Pointer), cchCount1, + Pointer.Create(lpString2.Pointer), cchCount2), + 2 => CompareStringW(Locale, dwCmpFlags, + Pointer.Create(lpString1.Pointer), cchCount1, + Pointer.Create(lpString2.Pointer), cchCount2), + _ => throw new PlatformNotSupportedException() + }; +#endif + #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs new file mode 100644 index 00000000..4e13e71a --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs @@ -0,0 +1,121 @@ +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Memory; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class CompareString + { + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionStringAnsi() + { + string str1 = nameof(CompareString); + string str2 = nameof(CompareString); + + var result = CompareStringA(default, default, str1, str2); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionLpStr() + { + var str1 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); + + try + { + var result = CompareStringA(default, default, str1, -1, str2, -1); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + finally + { + Marshal.FreeCoTaskMem(str1.Pointer); + Marshal.FreeCoTaskMem(str2.Pointer); + } + } + + [FactWindowsOS] + public static void CanCallExternFunctionStringUnicode() + { + string str1 = nameof(CompareString); + string str2 = nameof(CompareString); + + var result = CompareStringW(default, default, str1, str2); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + + [FactWindowsOS] + public static void CanCallExternFunctionLpWStr() + { + var str1 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); + + try + { + var result = CompareStringW(default, default, str1, -1, str2, -1); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + finally + { + Marshal.FreeCoTaskMem(str1.Pointer); + Marshal.FreeCoTaskMem(str2.Pointer); + } + } + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionStringAuto() + { + string str1 = nameof(CompareString); + string str2 = nameof(CompareString); + + var result = CompareString(default, default, str1, str2); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionLpTStr() + { + var str1 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); + + try + { + var result = CompareString(default, default, str1, -1, str2, -1); + if (result == default) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.Equal(CSTR_RESULT.CSTR_EQUAL, result); + } + finally + { + Marshal.FreeCoTaskMem(str1.Pointer); + Marshal.FreeCoTaskMem(str2.Pointer); + } + } + } +} From 730fa614bf3d0f1253107b71972d98d03d5a7a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 15:16:11 +0200 Subject: [PATCH 48/50] Make CompareString parameters constant --- .../WinNlsFunctions.cs | 90 ++++++++++++++++--- .../WinNls.Test/CompareString.cs | 12 +-- 2 files changed, 86 insertions(+), 16 deletions(-) diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index 3949ba40..eb0dc040 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -358,6 +358,29 @@ private static extern CSTR_RESULT CompareStringA( [In] int cchCount2 ); + /// + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + public unsafe static CSTR_RESULT CompareStringA( + int Locale, + CSTR_FLAGS dwCmpFlags, + ReadOnlySpan lpString1, + int cchCount1, + ReadOnlySpan lpString2, + int cchCount2 + ) + { + fixed (byte* ptrString1 = lpString1) + fixed (byte* ptrString2 = lpString2) + return CompareStringA( + Locale, + dwCmpFlags, + Pointer.Create(ptrString1), + cchCount1, + Pointer.Create(ptrString2), + cchCount2 + ); + } + /// [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] [SuppressMessage("Globalization", @@ -369,9 +392,9 @@ public static extern CSTR_RESULT CompareStringA( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] CSTR_FLAGS dwCmpFlags, - [In] LPSTR lpString1, + [In] LPCSTR lpString1, [In] int cchCount1, - [In] LPSTR lpString2, + [In] LPCSTR lpString2, [In] int cchCount2 ); #endregion @@ -405,6 +428,26 @@ private static extern CSTR_RESULT CompareStringW( [In] int cchCount2 ); + /// + public unsafe static CSTR_RESULT CompareStringW( + int Locale, + CSTR_FLAGS dwCmpFlags, + ReadOnlySpan lpString1, + ReadOnlySpan lpString2 + ) + { + fixed (char* ptrString1 = lpString1) + fixed (char* ptrString2 = lpString2) + return CompareStringW( + Locale, + dwCmpFlags, + Pointer.Create(ptrString1), + lpString1.Length, + Pointer.Create(ptrString2), + lpString2.Length + ); + } + /// [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] [return: MarshalAs(UnmanagedType.I4)] @@ -412,9 +455,9 @@ public static extern CSTR_RESULT CompareStringW( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] CSTR_FLAGS dwCmpFlags, - [In] LPWSTR lpString1, + [In] LPCWSTR lpString1, [In] int cchCount1, - [In] LPWSTR lpString2, + [In] LPCWSTR lpString2, [In] int cchCount2 ); #endregion @@ -510,6 +553,29 @@ [In] int cchCount2 }; #endif + /// + [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] + public unsafe static CSTR_RESULT CompareString( + int Locale, + CSTR_FLAGS dwCmpFlags, + ReadOnlySpan lpString1, + int cchCount1, + ReadOnlySpan lpString2, + int cchCount2 + ) + { + fixed (byte* ptrString1 = lpString1) + fixed (byte* ptrString2 = lpString2) + return CompareString( + Locale, + dwCmpFlags, + Pointer.Create(ptrString1), + cchCount1, + Pointer.Create(ptrString2), + cchCount2 + ); + } + /// [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] #if !NETSTANDARD1_3 @@ -526,9 +592,9 @@ CSTR_RESULT CompareString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] CSTR_FLAGS dwCmpFlags, - [In] LPTSTR lpString1, + [In] LPCTSTR lpString1, [In] int cchCount1, - [In] LPTSTR lpString2, + [In] LPCTSTR lpString2, [In] int cchCount2 ) #if !NETSTANDARD1_3 @@ -537,14 +603,18 @@ [In] int cchCount2 => Marshal.SystemDefaultCharSize switch { 1 => CompareStringA(Locale, dwCmpFlags, - Pointer.Create(lpString1.Pointer), cchCount1, - Pointer.Create(lpString2.Pointer), cchCount2), + Pointer.Create(lpString1.Pointer), cchCount1, + Pointer.Create(lpString2.Pointer), cchCount2), 2 => CompareStringW(Locale, dwCmpFlags, - Pointer.Create(lpString1.Pointer), cchCount1, - Pointer.Create(lpString2.Pointer), cchCount2), + Pointer.Create(lpString1.Pointer), cchCount1, + Pointer.Create(lpString2.Pointer), cchCount2), _ => throw new PlatformNotSupportedException() }; #endif #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1626 + #region FindNLSString function + + #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs index 4e13e71a..cb596847 100644 --- a/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/CompareString.cs @@ -30,8 +30,8 @@ public static void CanCallExternFunctionStringAnsi() [Obsolete("Deprecated Win API")] public static void CanCallExternFunctionLpStr() { - var str1 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); - var str2 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); + var str1 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemAnsi(nameof(CompareString))); try { @@ -64,8 +64,8 @@ public static void CanCallExternFunctionStringUnicode() [FactWindowsOS] public static void CanCallExternFunctionLpWStr() { - var str1 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); - var str2 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); + var str1 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemUni(nameof(CompareString))); try { @@ -100,8 +100,8 @@ public static void CanCallExternFunctionStringAuto() [Obsolete("Deprecated Win API")] public static void CanCallExternFunctionLpTStr() { - var str1 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); - var str2 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); + var str1 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); + var str2 = Pointer.Create(Marshal.StringToCoTaskMemAuto(nameof(CompareString))); try { From fb570eba43ed43ae41999f637d4dd2dc6314c975 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Sun, 19 Apr 2020 18:11:05 +0200 Subject: [PATCH 49/50] FindNLSString function, winnls.h line 1637 --- .../{CSTR_FLAGS.cs => NLSSTRING_FLAGS.cs} | 47 ++++- .../WinNlsFunctions.cs | 161 ++++++++++++++++-- .../WinNls.Test/FindNLSString.cs | 73 ++++++++ 3 files changed, 267 insertions(+), 14 deletions(-) rename src-native/THNETII.WinApi.Headers.WinNls/{CSTR_FLAGS.cs => NLSSTRING_FLAGS.cs} (66%) create mode 100644 test/THNETII.WinApi.Native.Test/WinNls.Test/FindNLSString.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs b/src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs similarity index 66% rename from src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs rename to src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs index 4baf4105..2d1928f2 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/CSTR_FLAGS.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs @@ -3,8 +3,11 @@ namespace THNETII.WinApi.Native.WinNls { [Flags] - public enum CSTR_FLAGS : int + public enum NLSSTRING_FLAGS : int { + // + // String Flags. + // /// /// Ignore case. For many scripts (notably Latin scripts), coincides with . /// ignores any tertiary distinction, whether it is actually linguistic case or not. For example, in Arabic and Indic scripts, this distinguishes alternate forms of a character, but the differences do not correspond to linguistic case. causes the function to ignore only actual linguistic casing, instead of ignoring the third sorting weight. @@ -37,6 +40,48 @@ public enum CSTR_FLAGS : int /// Use the default linguistic rules for casing, instead of file system rules. Note that most scenarios for use this flag. This flag does not have to be used when your application calls . NORM_LINGUISTIC_CASING = WinNlsConstants.NORM_LINGUISTIC_CASING, + // + // Search Flags + // + /// Test to find out if the value to find is the first value in the source string. + FIND_STARTSWITH = WinNlsConstants.FIND_STARTSWITH, + /// Test to find out if the value to find is the last value in the source string. + FIND_ENDSWITH = WinNlsConstants.FIND_ENDSWITH, + /// Search the string, starting with the first character of the string. + FIND_FROMSTART = WinNlsConstants.FIND_FROMSTART, + /// Search the string in the reverse direction, starting with the last character of the string. + FIND_FROMEND = WinNlsConstants.FIND_FROMEND, + + // + // Sorting Flags. + // + // WORD Sort: culturally correct sort + // hyphen and apostrophe are special cased + // example: "coop" and "co-op" will sort together in a list + // + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // co-op <------- hyphen (punctuation) + // cork + // went + // were + // we're <------- apostrophe (punctuation) + // + // + // STRING Sort: hyphen and apostrophe will sort with all other symbols + // + // co-op <------- hyphen (punctuation) + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // cork + // we're <------- apostrophe (punctuation) + // went + // were + // /// Treat punctuation the same as symbols. SORT_STRINGSORT = WinNlsConstants.SORT_STRINGSORT, /// Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10". diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index eb0dc040..a3b81eb0 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -329,7 +329,7 @@ out CPINFOEX lpCPInfoEx [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public static CSTR_RESULT CompareStringA( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -351,7 +351,7 @@ string lpString2 private static extern CSTR_RESULT CompareStringA( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -362,7 +362,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public unsafe static CSTR_RESULT CompareStringA( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, ReadOnlySpan lpString1, int cchCount1, ReadOnlySpan lpString2, @@ -391,7 +391,7 @@ int cchCount2 public static extern CSTR_RESULT CompareStringA( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] LPCSTR lpString1, [In] int cchCount1, [In] LPCSTR lpString2, @@ -403,7 +403,7 @@ [In] int cchCount2 /// public static CSTR_RESULT CompareStringW( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -421,7 +421,7 @@ string lpString2 private static extern CSTR_RESULT CompareStringW( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -431,7 +431,7 @@ [In] int cchCount2 /// public unsafe static CSTR_RESULT CompareStringW( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, ReadOnlySpan lpString1, ReadOnlySpan lpString2 ) @@ -454,7 +454,7 @@ ReadOnlySpan lpString2 public static extern CSTR_RESULT CompareStringW( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] LPCWSTR lpString1, [In] int cchCount1, [In] LPCWSTR lpString2, @@ -492,7 +492,7 @@ [In] int cchCount2 /// /// See Remarks for . /// If your application is calling the ANSI version of , the function converts parameters via the default code page of the supplied locale. Thus, an application can never use to handle UTF-8 text. - /// Normally, for case-insensitive comparisons, maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azerbaijani. The flag overrides this behavior for Turkish or Azerbaijani. If this flag is specified in conjunction with Turkish or Azerbaijani, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130). + /// Normally, for case-insensitive comparisons, maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azerbaijani. The flag overrides this behavior for Turkish or Azerbaijani. If this flag is specified in conjunction with Turkish or Azerbaijani, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130). /// /// /// Requirements @@ -504,10 +504,16 @@ [In] int cchCount2 /// /// The native library containg the function could not be found. /// Unable to find the entry point for the function in the native library. + /// + /// Handling Sorting in Your Applications + /// National Language Support + /// National Language Support Functions + /// Security Considerations: International Features + /// Using Unicode Normalization to Represent Strings [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public static CSTR_RESULT CompareString( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -534,7 +540,7 @@ private static CSTR_RESULT CompareString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -557,7 +563,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public unsafe static CSTR_RESULT CompareString( int Locale, - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, ReadOnlySpan lpString1, int cchCount1, ReadOnlySpan lpString2, @@ -591,7 +597,7 @@ public static CSTR_RESULT CompareString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - CSTR_FLAGS dwCmpFlags, + NLSSTRING_FLAGS dwCmpFlags, [In] LPCTSTR lpString1, [In] int cchCount1, [In] LPCTSTR lpString2, @@ -614,7 +620,136 @@ [In] int cchCount2 #endregion // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1626 #region FindNLSString function + /// + /// Locates a Unicode string (wide characters) or its equivalent in another Unicode string for a locale specified by identifier. + /// Because strings with very different binary representations can compare as identical, this function can raise certain security concerns. For more information, see the discussion of comparison functions in Security Considerations: International Features. + /// For interoperability reasons, the application should prefer the function because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Although supports custom locales, most applications should use for this type of support. + /// + /// + /// Locale identifier that specifies the locale. You can use the macro to create an identifier or use one of the following predefined values. + /// + /// + /// + /// + /// + /// Windows Vista and later: The following custom locale identifiers are also supported. + /// + /// + /// + /// + /// + /// + /// Flags specifying details of the find operation. For detailed definitions, see the dwFindNLSStringFlags parameter of . + /// + /// The source string, in which the function searches for the string specified by . + /// The application cannot specify 0 (zero) or any negative number other than -1 for the parameter specifying the length of the string (if any). The application specifies -1 for the length if the source string is null-terminated and the function should calculate the size automatically. + /// + /// + /// The search string, for which the function searches in the source string. + /// The application cannot specify 0 (zero) or any negative number other than -1 for the parameter specifying the length of the string (if any). The application specifies -1 for the length if the source string is null-terminated and the function should calculate the size automatically. + /// + /// Receives the length of the string that the function finds. For details, see the pcchFound parameter of . + /// + /// Returns a 0-based index into the source string indicated by if successful. In combination with the value in , this index provides the exact location of the entire found string in the source string. A return value of 0 (zero) is an error-free index into the source string, and the matching string is in the source string at offset 0. + /// + /// The function returns -1 if it does not succeed. To get extended error information, the application can call , which can return one of the following error codes: + /// + /// Error codeReason + /// The values supplied for flags were not valid. + /// Any of the parameter values was invalid. + /// The action completed successfully but yielded no results. + /// + /// + /// + /// + /// See Remarks for . + /// + /// + /// Requirements + /// Minimum supported client:Windows Vista [desktop apps only] + /// Minimum supported server:Windows Server 2008 [desktop apps only] + /// + /// + /// Microsoft Docs page: FindNLSString function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// + /// Handling Sorting in Your Applications + /// + /// National Language Support + /// National Language Support Functions + /// Security Considerations: International Features + [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] + public static int FindNLSString( + int Locale, + NLSSTRING_FLAGS dwFindNLSStringFlags, + string lpStringSource, + string lpStringValue, + out int pcchFound + ) => + FindNLSString( + Locale, + dwFindNLSStringFlags, + lpStringSource, + lpStringSource?.Length ?? 0, + lpStringValue, + lpStringValue?.Length ?? 0, + out pcchFound + ); + + [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true)] + private static extern int FindNLSString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + NLSSTRING_FLAGS dwFindNLSStringFlags, + [In, MarshalAs(UnmanagedType.LPWStr)] + string lpStringSource, + [In] int cchSource, + [In, MarshalAs(UnmanagedType.LPWStr)] + string lpStringValue, + [In] int cchValue, + out int pcchFound + ); + + /// + [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] + public static unsafe int FindNLSString( + int Locale, + NLSSTRING_FLAGS dwFindNLSStringFlags, + ReadOnlySpan lpStringSource, + ReadOnlySpan lpStringValue, + out int pcchFound + ) + { + fixed (char* ptrStringSource = lpStringSource) + fixed (char* ptrStringValue = lpStringValue) + return FindNLSString( + Locale, + dwFindNLSStringFlags, + Pointer.Create(ptrStringSource), + lpStringSource.Length, + Pointer.Create(ptrStringValue), + lpStringValue.Length, + out pcchFound + ); + } + /// + [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true)] + public static extern int FindNLSString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + NLSSTRING_FLAGS dwFindNLSStringFlags, + [In] LPCWSTR lpStringSource, + [In] int cchSource, + [In] LPCWSTR lpStringValue, + [In] int cchValue, + out int pcchFound + ); #endregion } } diff --git a/test/THNETII.WinApi.Native.Test/WinNls.Test/FindNLSString.cs b/test/THNETII.WinApi.Native.Test/WinNls.Test/FindNLSString.cs new file mode 100644 index 00000000..c9a7f1aa --- /dev/null +++ b/test/THNETII.WinApi.Native.Test/WinNls.Test/FindNLSString.cs @@ -0,0 +1,73 @@ +using System; +using System.ComponentModel; +using System.Runtime.InteropServices; + +using THNETII.InteropServices.Memory; + +using Xunit; + +namespace THNETII.WinApi.Native.WinNls.Test +{ + using static WinNlsFunctions; + + public static class FindNLSString + { + private static readonly string TestSource = typeof(FindNLSString).FullName; + private static readonly string TestValue = nameof(Test); + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionString() + { + string source = new string(TestSource); + string value = new string(TestValue); + + int idx = FindNLSString(default, default, source, value, out int len); + if (idx < 0) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.InRange(idx, 0, source.Length); + Assert.Equal(value.Length, len); + } + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionSpan() + { + ReadOnlySpan source = new string(TestSource).AsSpan(); + ReadOnlySpan value = new string(TestValue).AsSpan(); + + int idx = FindNLSString(default, default, source, value, out int len); + if (idx < 0) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.InRange(idx, 0, source.Length); + Assert.Equal(value.Length, len); + } + + [FactWindowsOS] + [Obsolete("Deprecated Win API")] + public static void CanCallExternFunctionLpWStr() + { + var source = Pointer.Create(Marshal.StringToCoTaskMemUni(TestSource)); + var value = Pointer.Create(Marshal.StringToCoTaskMemUni(TestValue)); + + try + { + int idx = FindNLSString(default, default, source, -1, value, -1, out int len); + if (idx < 0) + throw new Win32Exception(Marshal.GetLastWin32Error()); + + Assert.InRange(idx, 0, int.MaxValue); + var expect = value.GetReadOnlySpan(len).ToArray(); + var found = source.GetReadOnlySpan(idx + len).Slice(idx).ToArray(); + Assert.Equal(expect, found); + } + finally + { + Marshal.FreeCoTaskMem(source.Pointer); + Marshal.FreeCoTaskMem(value.Pointer); + } + } + } +} From 940e62b7fdac396807ee718f193fee45228db79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=B8is=C3=A6ther=20Rasch?= Date: Thu, 23 Apr 2020 00:41:28 +0200 Subject: [PATCH 50/50] LCMapString functions, winnls.h line 1671 --- .../NLSSTRING_FLAGS.cs | 90 ----- .../NLS_FLAGS.cs | 284 +++++++++++++++ .../WinNlsFunctions.cs | 338 +++++++++++++++++- 3 files changed, 605 insertions(+), 107 deletions(-) delete mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs create mode 100644 src-native/THNETII.WinApi.Headers.WinNls/NLS_FLAGS.cs diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs b/src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs deleted file mode 100644 index 2d1928f2..00000000 --- a/src-native/THNETII.WinApi.Headers.WinNls/NLSSTRING_FLAGS.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; - -namespace THNETII.WinApi.Native.WinNls -{ - [Flags] - public enum NLSSTRING_FLAGS : int - { - // - // String Flags. - // - /// - /// Ignore case. For many scripts (notably Latin scripts), coincides with . - /// ignores any tertiary distinction, whether it is actually linguistic case or not. For example, in Arabic and Indic scripts, this distinguishes alternate forms of a character, but the differences do not correspond to linguistic case. causes the function to ignore only actual linguistic casing, instead of ignoring the third sorting weight. - /// With this flag set, the function ignores the distinction between the wide and narrow forms of the CJK compatibility characters. - /// - NORM_IGNORECASE = WinNlsConstants.NORM_IGNORECASE, - /// - /// Ignore nonspacing characters. For many scripts (notably Latin scripts), coincides with . - /// ignores any secondary distinction, whether it is a diacritic or not. Scripts for Korean, Japanese, Chinese, and Indic languages, among others, use this distinction for purposes other than diacritics. causes the function to ignore only actual diacritics, instead of ignoring the second sorting weight. - /// only has an effect for locales in which accented characters are sorted in a second pass from main characters. Normally all characters in the string are first compared without regard to accents and, if the strings are equal, a second pass over the strings is performed to compare accents. This flag causes the second pass to not be performed. For locales that sort accented characters in the first pass, this flag has no effect. - /// - NORM_IGNORENONSPACE = WinNlsConstants.NORM_IGNORENONSPACE, - /// Ignore symbols and punctuation. - NORM_IGNORESYMBOLS = WinNlsConstants.NORM_IGNORESYMBOLS, - - /// - /// Ignore case, as linguistically appropriate. - /// - LINGUISTIC_IGNORECASE = WinNlsConstants.LINGUISTIC_IGNORECASE, - /// - /// Ignore nonspacing characters, as linguistically appropriate. - /// This flag does not always produce predictable results when used with decomposed characters, that is, characters in which a base character and one or more nonspacing characters each have distinct code point values. - /// - LINGUISTIC_IGNOREDIACRITIC = WinNlsConstants.LINGUISTIC_IGNOREDIACRITIC, - - /// Do not differentiate between hiragana and katakana characters. Corresponding hiragana and katakana characters compare as equal. - NORM_IGNOREKANATYPE = WinNlsConstants.NORM_IGNOREKANATYPE, - /// Ignore the difference between half-width and full-width characters, for example, C a t == cat. The full-width form is a formatting distinction used in Chinese and Japanese scripts. - NORM_IGNOREWIDTH = WinNlsConstants.NORM_IGNOREWIDTH, - /// Use the default linguistic rules for casing, instead of file system rules. Note that most scenarios for use this flag. This flag does not have to be used when your application calls . - NORM_LINGUISTIC_CASING = WinNlsConstants.NORM_LINGUISTIC_CASING, - - // - // Search Flags - // - /// Test to find out if the value to find is the first value in the source string. - FIND_STARTSWITH = WinNlsConstants.FIND_STARTSWITH, - /// Test to find out if the value to find is the last value in the source string. - FIND_ENDSWITH = WinNlsConstants.FIND_ENDSWITH, - /// Search the string, starting with the first character of the string. - FIND_FROMSTART = WinNlsConstants.FIND_FROMSTART, - /// Search the string in the reverse direction, starting with the last character of the string. - FIND_FROMEND = WinNlsConstants.FIND_FROMEND, - - // - // Sorting Flags. - // - // WORD Sort: culturally correct sort - // hyphen and apostrophe are special cased - // example: "coop" and "co-op" will sort together in a list - // - // co_op <------- underscore (symbol) - // coat - // comb - // coop - // co-op <------- hyphen (punctuation) - // cork - // went - // were - // we're <------- apostrophe (punctuation) - // - // - // STRING Sort: hyphen and apostrophe will sort with all other symbols - // - // co-op <------- hyphen (punctuation) - // co_op <------- underscore (symbol) - // coat - // comb - // coop - // cork - // we're <------- apostrophe (punctuation) - // went - // were - // - /// Treat punctuation the same as symbols. - SORT_STRINGSORT = WinNlsConstants.SORT_STRINGSORT, - /// Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10". - SORT_DIGITSASNUMBERS = WinNlsConstants.SORT_DIGITSASNUMBERS, - } -} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/NLS_FLAGS.cs b/src-native/THNETII.WinApi.Headers.WinNls/NLS_FLAGS.cs new file mode 100644 index 00000000..37d34a84 --- /dev/null +++ b/src-native/THNETII.WinApi.Headers.WinNls/NLS_FLAGS.cs @@ -0,0 +1,284 @@ +using System; + +namespace THNETII.WinApi.Native.WinNls +{ + using static WinNlsFunctions; + + /// + /// Combines flags values from different flag enumeration types together for + /// calls to methods defined in . + /// + public static class NLS_FLAGS + { + /// + /// Combines string-comparison flags for calls to and + /// + /// + /// + public static SORT_FLAGS CmpFlags( + STRING_FLAGS string_flags = default, + SORT_FLAGS sort_flags = default) => + (SORT_FLAGS)string_flags | sort_flags; + + /// + /// Combines string-finding flags for calls to and + /// + /// + /// + public static FIND_FLAGS FindFlags( + STRING_FLAGS string_flags = default, + FIND_FLAGS find_flags = default) => + (FIND_FLAGS)string_flags | find_flags; + + /// + /// Combines locale dependant mapping flags for calls to and . + /// + /// + /// + public static LCMAP_FLAGS LcMapFlags( + STRING_FLAGS string_flags = default, + SORT_FLAGS sort_flags = default, + LCMAP_FLAGS lcmap_flags = default) => + (LCMAP_FLAGS)string_flags | (LCMAP_FLAGS)sort_flags | lcmap_flags; + } + + /// + /// String Flags. + /// + [Flags] + public enum STRING_FLAGS : int + { + /// + /// Ignore case. For many scripts (notably Latin scripts), coincides with . + /// ignores any tertiary distinction, whether it is actually linguistic case or not. For example, in Arabic and Indic scripts, this distinguishes alternate forms of a character, but the differences do not correspond to linguistic case. causes the function to ignore only actual linguistic casing, instead of ignoring the third sorting weight. + /// With this flag set, the function ignores the distinction between the wide and narrow forms of the CJK compatibility characters. + /// + NORM_IGNORECASE = WinNlsConstants.NORM_IGNORECASE, + /// + /// Ignore nonspacing characters. For many scripts (notably Latin scripts), coincides with . + /// ignores any secondary distinction, whether it is a diacritic or not. Scripts for Korean, Japanese, Chinese, and Indic languages, among others, use this distinction for purposes other than diacritics. causes the function to ignore only actual diacritics, instead of ignoring the second sorting weight. + /// only has an effect for locales in which accented characters are sorted in a second pass from main characters. Normally all characters in the string are first compared without regard to accents and, if the strings are equal, a second pass over the strings is performed to compare accents. This flag causes the second pass to not be performed. For locales that sort accented characters in the first pass, this flag has no effect. + /// + NORM_IGNORENONSPACE = WinNlsConstants.NORM_IGNORENONSPACE, + /// Ignore symbols and punctuation. + NORM_IGNORESYMBOLS = WinNlsConstants.NORM_IGNORESYMBOLS, + + /// + /// Ignore case, as linguistically appropriate. + /// + LINGUISTIC_IGNORECASE = WinNlsConstants.LINGUISTIC_IGNORECASE, + /// + /// Ignore nonspacing characters, as linguistically appropriate. + /// This flag does not always produce predictable results when used with decomposed characters, that is, characters in which a base character and one or more nonspacing characters each have distinct code point values. + /// + LINGUISTIC_IGNOREDIACRITIC = WinNlsConstants.LINGUISTIC_IGNOREDIACRITIC, + + /// Do not differentiate between hiragana and katakana characters. Corresponding hiragana and katakana characters compare as equal. + NORM_IGNOREKANATYPE = WinNlsConstants.NORM_IGNOREKANATYPE, + /// Ignore the difference between half-width and full-width characters, for example, C a t == cat. The full-width form is a formatting distinction used in Chinese and Japanese scripts. + NORM_IGNOREWIDTH = WinNlsConstants.NORM_IGNOREWIDTH, + /// Use the default linguistic rules for casing, instead of file system rules. Note that most scenarios for use this flag. This flag does not have to be used when your application calls . + NORM_LINGUISTIC_CASING = WinNlsConstants.NORM_LINGUISTIC_CASING, + } + + /// + /// Locale Independent Mapping Flags. + /// + [Flags] + public enum MAP_FLAGS : int + { + /// + MAP_FOLDCZONE = WinNlsConstants.MAP_FOLDCZONE, + /// + MAP_PRECOMPOSED = WinNlsConstants.MAP_PRECOMPOSED, + /// + MAP_COMPOSITE = WinNlsConstants.MAP_COMPOSITE, + /// + MAP_FOLDDIGITS = WinNlsConstants.MAP_FOLDDIGITS, + + /// + MAP_EXPAND_LIGATURES = WinNlsConstants.MAP_EXPAND_LIGATURES, + } + + /// + /// Locale Dependent Mapping Flags. + /// + [Flags] + public enum LCMAP_FLAGS : int + { + /// For locales and scripts capable of handling uppercase and lowercase, map all characters to lowercase. + LCMAP_LOWERCASE = WinNlsConstants.LCMAP_LOWERCASE, + /// + /// For locales and scripts capable of handling uppercase and lowercase, map all characters to uppercase. + /// + LCMAP_UPPERCASE = WinNlsConstants.LCMAP_UPPERCASE, + /// + /// Windows 7: Map all characters to title case, in which the first letter of each major word is capitalized. + /// + LCMAP_TITLECASE = WinNlsConstants.LCMAP_TITLECASE, + + /// + /// Produce a normalized sort key. If the flag is not specified, the function performs string mapping. For details of sort key generation and string mapping, see the Remarks section of . + /// + LCMAP_SORTKEY = WinNlsConstants.LCMAP_SORTKEY, + /// Use byte reversal. For example, if the application passes in 0x3450 0x4822, the result is 0x5034 0x2248. + LCMAP_BYTEREV = WinNlsConstants.LCMAP_BYTEREV, + + /// Map all katakana characters to hiragana. This flag and are mutually exclusive. + LCMAP_HIRAGANA = WinNlsConstants.LCMAP_HIRAGANA, + /// Map all hiragana characters to katakana. This flag and are mutually exclusive. + LCMAP_KATAKANA = WinNlsConstants.LCMAP_KATAKANA, + /// Use narrow characters where applicable. This flag and are mutually exclusive. + LCMAP_HALFWIDTH = WinNlsConstants.LCMAP_HALFWIDTH, + /// Use Unicode (wide) characters where applicable. This flag and are mutually exclusive. With this flag, the mapping may use Normalization Form C even if an input character is already full-width. For example, the string "は゛" (which is already full-width) is normalized to "ば". See Unicode normalization forms. + LCMAP_FULLWIDTH = WinNlsConstants.LCMAP_FULLWIDTH, + + /// Use linguistic rules for casing, instead of file system rules (default). This flag is valid with or only. + LCMAP_LINGUISTIC_CASING = WinNlsConstants.LCMAP_LINGUISTIC_CASING, + + /// + /// Map traditional Chinese characters to simplified Chinese characters. This flag and are mutually exclusive. + /// + LCMAP_SIMPLIFIED_CHINESE = WinNlsConstants.LCMAP_SIMPLIFIED_CHINESE, + /// + /// Map simplified Chinese characters to traditional Chinese characters. This flag and are mutually exclusive. + /// + LCMAP_TRADITIONAL_CHINESE = WinNlsConstants.LCMAP_TRADITIONAL_CHINESE, + + /// + /// Return a token representing the resolved sort parameters for the locale (like locale name), so future calls can pass for the sort name and pass the previously queried sort handle as the last parameter (sortHandle) in subsequent calls to or . + /// requires that the output buffer be of size of a pointer on the platform. + /// + /// + /// The use of a sort handle results in minimal performance improvements and is discouraged. + /// + LCMAP_SORTHANDLE = WinNlsConstants.LCMAP_SORTHANDLE, + /// + /// Return a hash of the raw sort weights of a string. + /// Strings that appear equivalent typically return the same hash (for example, "hello" and "HELLO" with ). However, some complex cases, such as East Asian languages, can have similar strings with identical weights that compare as equal but do not return the same hash. + /// requires that the output buffer be of size sizeof(int). + /// + LCMAP_HASH = WinNlsConstants.LCMAP_HASH, + } + + /// + /// Search Flags + /// + [Flags] + public enum FIND_FLAGS : int + { + /// + /// Test to find out if the value to find is the first value in the source string. + /// + FIND_STARTSWITH = WinNlsConstants.FIND_STARTSWITH, + /// + /// Test to find out if the value to find is the last value in the source string. + /// + FIND_ENDSWITH = WinNlsConstants.FIND_ENDSWITH, + /// + /// Search the string, starting with the first character of the string. + /// + FIND_FROMSTART = WinNlsConstants.FIND_FROMSTART, + /// + /// Search the string in the reverse direction, starting with the last character of the string. + /// + FIND_FROMEND = WinNlsConstants.FIND_FROMEND, + } + + /// + /// Language Group Enumeration Flags. + /// + [Obsolete(WinNlsConstants.LGRPID_DEPRECATION_MESSAGE)] + [Flags] + public enum LGRPID_FLAGS : int + { + /// + LGRPID_INSTALLED = WinNlsConstants.LGRPID_INSTALLED, + /// + LGRPID_SUPPORTED = WinNlsConstants.LGRPID_SUPPORTED, + } + + /// + /// Locale Enumeration Flags. + /// + [Flags] + public enum LCID_FLAGS : int + { + /// + LCID_INSTALLED = WinNlsConstants.LCID_INSTALLED, + /// + LCID_SUPPORTED = WinNlsConstants.LCID_SUPPORTED, + /// + LCID_ALTERNATE_SORTS = WinNlsConstants.LCID_ALTERNATE_SORTS, + } + + /// + /// Locale Enumeration Flags. + /// + [Flags] + public enum LOCALE_FLAGS : int + { + /// + LCID_INSTALLED = WinNlsConstants.LCID_INSTALLED, + /// + LCID_SUPPORTED = WinNlsConstants.LCID_SUPPORTED, + /// + LCID_ALTERNATE_SORTS = WinNlsConstants.LCID_ALTERNATE_SORTS, + } + + /// + /// Code Page Enumeration Flags. + /// + [Flags] + public enum CP_FLAGS : int + { + /// + CP_INSTALLED = WinNlsConstants.CP_INSTALLED, + /// + CP_SUPPORTED = WinNlsConstants.CP_SUPPORTED, + } + + /// + /// Sorting Flags. + /// + [Flags] + public enum SORT_FLAGS : int + { + // WORD Sort: culturally correct sort + // hyphen and apostrophe are special cased + // example: "coop" and "co-op" will sort together in a list + // + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // co-op <------- hyphen (punctuation) + // cork + // went + // were + // we're <------- apostrophe (punctuation) + // + // + // STRING Sort: hyphen and apostrophe will sort with all other symbols + // + // co-op <------- hyphen (punctuation) + // co_op <------- underscore (symbol) + // coat + // comb + // coop + // cork + // we're <------- apostrophe (punctuation) + // went + // were + // + /// + /// Treat punctuation the same as symbols. + /// + SORT_STRINGSORT = WinNlsConstants.SORT_STRINGSORT, + + /// + /// Windows 7: Treat digits as numbers during sorting, for example, sort "2" before "10". + /// + SORT_DIGITSASNUMBERS = WinNlsConstants.SORT_DIGITSASNUMBERS, + } +} diff --git a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs index a3b81eb0..03c61e3e 100644 --- a/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs +++ b/src-native/THNETII.WinApi.Headers.WinNls/WinNlsFunctions.cs @@ -4,6 +4,7 @@ using THNETII.WinApi.Native.WinError; using THNETII.InteropServices.Memory; +using System.Text; #if NETSTANDARD1_3 using EntryPointNotFoundException = System.Exception; @@ -329,7 +330,7 @@ out CPINFOEX lpCPInfoEx [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public static CSTR_RESULT CompareStringA( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -351,7 +352,7 @@ string lpString2 private static extern CSTR_RESULT CompareStringA( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -362,7 +363,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public unsafe static CSTR_RESULT CompareStringA( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, ReadOnlySpan lpString1, int cchCount1, ReadOnlySpan lpString2, @@ -391,7 +392,7 @@ int cchCount2 public static extern CSTR_RESULT CompareStringA( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] LPCSTR lpString1, [In] int cchCount1, [In] LPCSTR lpString2, @@ -403,7 +404,7 @@ [In] int cchCount2 /// public static CSTR_RESULT CompareStringW( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -421,7 +422,7 @@ string lpString2 private static extern CSTR_RESULT CompareStringW( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -431,7 +432,7 @@ [In] int cchCount2 /// public unsafe static CSTR_RESULT CompareStringW( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, ReadOnlySpan lpString1, ReadOnlySpan lpString2 ) @@ -454,7 +455,7 @@ ReadOnlySpan lpString2 public static extern CSTR_RESULT CompareStringW( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] LPCWSTR lpString1, [In] int cchCount1, [In] LPCWSTR lpString2, @@ -492,7 +493,7 @@ [In] int cchCount2 /// /// See Remarks for . /// If your application is calling the ANSI version of , the function converts parameters via the default code page of the supplied locale. Thus, an application can never use to handle UTF-8 text. - /// Normally, for case-insensitive comparisons, maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azerbaijani. The flag overrides this behavior for Turkish or Azerbaijani. If this flag is specified in conjunction with Turkish or Azerbaijani, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130). + /// Normally, for case-insensitive comparisons, maps the lowercase "i" to the uppercase "I", even when the locale is Turkish or Azerbaijani. The flag overrides this behavior for Turkish or Azerbaijani. If this flag is specified in conjunction with Turkish or Azerbaijani, LATIN SMALL LETTER DOTLESS I (U+0131) is the lowercase form of LATIN CAPITAL LETTER I (U+0049) and LATIN SMALL LETTER I (U+0069) is the lowercase form of LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130). /// /// /// Requirements @@ -513,7 +514,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public static CSTR_RESULT CompareString( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, string lpString1, string lpString2 ) => @@ -540,7 +541,7 @@ private static CSTR_RESULT CompareString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] string lpString1, [In] int cchCount1, [In] string lpString2, @@ -563,7 +564,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: StringApiSetFunction.CompareStringEx is preferred")] public unsafe static CSTR_RESULT CompareString( int Locale, - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, ReadOnlySpan lpString1, int cchCount1, ReadOnlySpan lpString2, @@ -597,7 +598,7 @@ public static CSTR_RESULT CompareString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwCmpFlags, + SORT_FLAGS dwCmpFlags, [In] LPCTSTR lpString1, [In] int cchCount1, [In] LPCTSTR lpString2, @@ -684,7 +685,7 @@ [In] int cchCount2 [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] public static int FindNLSString( int Locale, - NLSSTRING_FLAGS dwFindNLSStringFlags, + FIND_FLAGS dwFindNLSStringFlags, string lpStringSource, string lpStringValue, out int pcchFound @@ -704,7 +705,7 @@ out pcchFound private static extern int FindNLSString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwFindNLSStringFlags, + FIND_FLAGS dwFindNLSStringFlags, [In, MarshalAs(UnmanagedType.LPWStr)] string lpStringSource, [In] int cchSource, @@ -718,7 +719,7 @@ out int pcchFound [Obsolete("DEPRECATED: FindNLSStringEx is preferred")] public static unsafe int FindNLSString( int Locale, - NLSSTRING_FLAGS dwFindNLSStringFlags, + FIND_FLAGS dwFindNLSStringFlags, ReadOnlySpan lpStringSource, ReadOnlySpan lpStringValue, out int pcchFound @@ -743,7 +744,7 @@ out pcchFound public static extern int FindNLSString( [In] int Locale, [In, MarshalAs(UnmanagedType.I4)] - NLSSTRING_FLAGS dwFindNLSStringFlags, + FIND_FLAGS dwFindNLSStringFlags, [In] LPCWSTR lpStringSource, [In] int cchSource, [In] LPCWSTR lpStringValue, @@ -751,5 +752,308 @@ public static extern int FindNLSString( out int pcchFound ); #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1641 + #region LCMapStringW function + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static int LCMapStringW( + int Locale, + MAP_FLAGS dwMapFlags, + string lpSrcStr, + StringBuilder lpDestStr + ) => + LCMapStringW( + Locale, + dwMapFlags, + lpSrcStr, + lpSrcStr?.Length ?? 0, + lpDestStr, + lpDestStr?.Capacity ?? 0 + ); + + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] + private static extern int LCMapStringW( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] string lpSrcStr, + [In] int cchSrc, + [Out] StringBuilder lpDestStr, + [In] int cchDest + ); + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static unsafe int LCMapStringW( + int Locale, + MAP_FLAGS dwMapFlags, + ReadOnlySpan lpSrcStr, + Span lpDestStr + ) + { + fixed (char* ptrSrcStr = lpSrcStr) + fixed (char* ptrDestStr = lpDestStr) + return LCMapStringW( + Locale, + dwMapFlags, + Pointer.Create(ptrSrcStr), + lpSrcStr.Length, + Pointer.Create(ptrDestStr), + lpDestStr.Length + ); + } + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Unicode)] + public static extern int LCMapStringW( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] LPCWSTR lpSrcStr, + [In] int cchSrc, + LPWSTR lpDestStr, + [In] int cchDest + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1656 + #region LCMapStringA function + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static int LCMapStringA( + int Locale, + MAP_FLAGS dwMapFlags, + string lpSrcStr, + StringBuilder lpDestStr + ) => + LCMapStringA( + Locale, + dwMapFlags, + lpSrcStr, + lpSrcStr?.Length ?? 0, + lpDestStr, + lpDestStr?.Capacity ?? 0 + ); + + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", Justification = nameof(CharSet.Ansi))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Ansi)] + private static extern int LCMapStringA( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] string lpSrcStr, + [In] int cchSrc, + [Out] StringBuilder lpDestStr, + [In] int cchDest + ); + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static unsafe int LCMapStringA( + int Locale, + MAP_FLAGS dwMapFlags, + ReadOnlySpan lpSrcStr, + int cchSrc, + Span lpDestStr, + int cchDest + ) + { + fixed (byte* ptrSrcStr = lpSrcStr) + fixed (byte* ptrDestStr = lpDestStr) + return LCMapStringA( + Locale, + dwMapFlags, + Pointer.Create(ptrSrcStr), + cchSrc, + Pointer.Create(ptrDestStr), + cchDest + ); + } + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Ansi)] + public static extern int LCMapStringA( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] LPCSTR lpSrcStr, + [In] int cchSrc, + LPSTR lpDestStr, + [In] int cchDest + ); + #endregion + // C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\WinNls.h, line 1652 + #region LCMapString function + /// + /// For a locale specified by identifier, maps one input character string to another using a specified transformation, or generates a sort key for the input string. + /// For interoperability reasons, the application should prefer the function to because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. This recommendation applies especially to custom locales, including those created by Microsoft. Any application that will be run only on Windows Vista and later should use . + /// + /// + /// Locale identifier that specifies the locale. You can use the macro to create an identifier or use one of the following predefined values. + /// + /// + /// + /// + /// + /// The following custom locale identifiers are also supported. + /// + /// + /// + /// + /// + /// + /// Flags specifying the type of transformation to use during string mapping or the type of sort key to generate. For detailed definitions, see the dwMapFlags parameter of . + /// + /// A source string that the function maps or uses for sort key generation. This string cannot have a size of 0. + /// The length of the source string can include the terminating null character, but does not have to. If the terminating null character is included, the mapping behavior of the function is not greatly affected because the terminating null character is considered to be unsortable and always maps to itself. + /// The application can set the length parameter (if any) to any negative value to specify that the source string is null-terminated. In this case, if is being used in its string-mapping mode, the function calculates the string length itself, and null-terminates the mapped string indicated by . + /// + /// + /// A buffer in which this function retrieves the mapped string or a sort key. When the application uses this function to generate a sort key, the destination string can contain an odd number of bytes. The flag only reverses an even number of bytes. The last byte (odd-positioned) in the sort key is not reversed. + /// The destination string can be the same as the source string only if or is set. Otherwise, the strings cannot be the same. If they are, the function fails. + /// Upon failure of the function, the destination buffer might contain either partial results or no results at all. In this case, it is recommended for your application to consider any results invalid. + /// If the length parameter (if any) for the destination string is set to 0, the functionn does not use the parameter and returns the required buffer size for the mapped string or sort key. + /// + /// + /// Returns the number of characters or bytes in the translated string or sort key, including a terminating null character, if successful. If the function succeeds and the value of the parameter specifying the length of (if any) is 0 (zero), the return value is the size of the buffer required to hold the translated string or sort key, including a terminating null character. + /// + /// The function returns 0 (zero) if it does not succeed. To get extended error information, the application can call , which can return one of the following error codes: + /// + /// Error codeReason + /// A supplied buffer size was not large enough, or it was incorrectly set to . + /// The values supplied for flags were not valid. + /// Any of the parameter values was invalid. + /// + /// + /// + /// + /// See Remarks for . + /// The ANSI version of maps strings to and from Unicode based on the default Windows (ANSI) code page associated with the specified locale. When the ANSI version of this function is used with a Unicode-only locale, the function can succeed because the operating system uses the value, representing the system default Windows ANSI code page. However, characters that are undefined in the system code page appear in the string as a question mark (?). + /// + /// + /// Requirements + /// Minimum supported client:Windows 2000 Professional [desktop apps only] + /// Minimum supported server:Windows 2000 Server [desktop apps only] + /// + /// + /// Microsoft Docs page: LCMapStringW function + /// + /// The native library containg the function could not be found. + /// Unable to find the entry point for the function in the native library. + /// + /// + /// + /// Handling Sorting in Your Applications + /// + /// National Language Support + /// National Language Support Functions + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static int LCMapString( + int Locale, + MAP_FLAGS dwMapFlags, + string lpSrcStr, + StringBuilder lpDestStr + ) => + LCMapString( + Locale, + dwMapFlags, + lpSrcStr, + lpSrcStr?.Length ?? 0, + lpDestStr, + lpDestStr?.Capacity ?? 0 + ); + + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] +#if !NETSTANDARD1_3 + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", Justification = nameof(CharSet.Auto))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto)] + private static extern +#else + private static +#endif + int LCMapString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] string lpSrcStr, + [In] int cchSrc, + [Out] StringBuilder lpDestStr, + [In] int cchDest + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => LCMapStringA(Locale, dwMapFlags, lpSrcStr, cchSrc, + lpDestStr, cchDest), + 2 => LCMapStringW(Locale, dwMapFlags, lpSrcStr, cchSrc, + lpDestStr, cchDest), + _ => throw new PlatformNotSupportedException() + }; +#endif + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] + public static unsafe int LCMapString( + int Locale, + MAP_FLAGS dwMapFlags, + ReadOnlySpan lpSrcStr, + int cchSrc, + Span lpDestStr, + int cchDest + ) + { + fixed (byte* ptrSrcStr = lpSrcStr) + fixed (byte* ptrDestStr = lpDestStr) + return LCMapString( + Locale, + dwMapFlags, + Pointer.Create(ptrSrcStr), + cchSrc, + Pointer.Create(ptrDestStr), + cchDest + ); + } + + /// + [Obsolete("DEPRECATED: LCMapStringEx is preferred")] +#if !NETSTANDARD1_3 + [SuppressMessage("Globalization", + "CA2101: Specify marshaling for P/Invoke string arguments", Justification = nameof(CharSet.Auto))] + [DllImport(Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true, CharSet = CharSet.Auto)] + public static extern +#else + public static +#endif + int LCMapString( + [In] int Locale, + [In, MarshalAs(UnmanagedType.I4)] + MAP_FLAGS dwMapFlags, + [In] LPCTSTR lpSrcStr, + [In] int cchSrc, + LPTSTR lpDestStr, + [In] int cchDest + ) +#if !NETSTANDARD1_3 + ; +#else + => Marshal.SystemDefaultCharSize switch + { + 1 => LCMapStringA(Locale, dwMapFlags, + Pointer.Create(lpSrcStr.Pointer), cchSrc, + Pointer.Create(lpDestStr.Pointer), cchDest), + 2 => LCMapStringW(Locale, dwMapFlags, + Pointer.Create(lpSrcStr.Pointer), cchSrc, + Pointer.Create(lpDestStr.Pointer), cchDest), + _ => throw new PlatformNotSupportedException() + }; +#endif + #endregion } }