#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using System; using System.Runtime.InteropServices; using System.Text; using Vanara.InteropServices; namespace Vanara.PInvoke { /// Items from the Imm32.dll public static partial class Imm32 { /// invalid dictionary format public static readonly HRESULT IFED_E_INVALID_FORMAT = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7301); /// no entry found in dictionary public static readonly HRESULT IFED_E_NO_ENTRY = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7304); /// dictionary is not found public static readonly HRESULT IFED_E_NOT_FOUND = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7300); /// not supported public static readonly HRESULT IFED_E_NOT_SUPPORTED = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7307); /// not a user dictionary public static readonly HRESULT IFED_E_NOT_USER_DIC = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7306); /// failed to open file public static readonly HRESULT IFED_E_OPEN_FAILED = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7302); /// dictionary is disconnected public static readonly HRESULT IFED_E_REGISTER_DISCONNECTED = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x730b); /// this routines doesn't support the current dictionary public static readonly HRESULT IFED_E_REGISTER_FAILED = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7305); /// improper POS is to be registered public static readonly HRESULT IFED_E_REGISTER_ILLEGAL_POS = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7309); /// improper word is to be registered public static readonly HRESULT IFED_E_REGISTER_IMPROPER_WORD = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x730a); /// failed to insert user comment public static readonly HRESULT IFED_E_USER_COMMENT = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7308); /// failed to write to file public static readonly HRESULT IFED_E_WRITE_FAILED = HRESULT.Make(true, HRESULT.FacilityCode.FACILITY_ITF, 0x7303); /// word already exists in dictionary but only comment data is updated public static readonly HRESULT IFED_S_COMMENT_CHANGED = HRESULT.Make(false, HRESULT.FacilityCode.FACILITY_ITF, 0x7203); /// dictionary is empty, no header information is returned public static readonly HRESULT IFED_S_EMPTY_DICTIONARY = HRESULT.Make(false, HRESULT.FacilityCode.FACILITY_ITF, 0x7201); /// no more entries in the dictionary public static readonly HRESULT IFED_S_MORE_ENTRIES = HRESULT.Make(false, HRESULT.FacilityCode.FACILITY_ITF, 0x7200); /// word already exists in dictionary public static readonly HRESULT IFED_S_WORD_EXISTS = HRESULT.Make(false, HRESULT.FacilityCode.FACILITY_ITF, 0x7202); /// Returns a pointer to an IFECommon interface. /// Address of the pointer variable that receives the IFECommon interface pointer of the object created. /// S_OK if successful, otherwise an OLE-defined error code. /// /// There is no import library available that defines this function. It is necessary to manually obtain a pointer to this function /// using LoadLibrary and GetProcAddress. /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-createifecommoninstance HRESULT CreateIFECommonInstance( [out] // VOID **ppvObj ); [UnmanagedFunctionPointer(CallingConvention.Winapi)] [PInvokeData("msime.h", MSDNShortId = "NF:msime.CreateIFECommonInstance")] public delegate HRESULT CreateIFECommonInstance(out IFECommon ppvObj); /// Returns a pointer to an IFEDictionary interface. /// Address of the pointer variable that receives the IFEDictionary interface pointer of the object created. /// S_OK if successful, otherwise an OLE-defined error code. /// /// There is no import library available that defines this function. It is necessary to manually obtain a pointer to this function /// using LoadLibrary and GetProcAddress. /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-createifedictionaryinstance HRESULT CreateIFEDictionaryInstance( // [out] VOID **ppvObj ); [UnmanagedFunctionPointer(CallingConvention.Winapi)] [PInvokeData("msime.h", MSDNShortId = "NF:msime.CreateIFEDictionaryInstance")] public delegate HRESULT CreateIFEDictionaryInstance(out IFEDictionary ppvObj); /// Returns a pointer to an IFELanguage interface. /// Reserved. Must be set to NULL. /// Address of the pointer variable that receives the IFELanguage interface pointer of the object created. /// S_OK if successful, otherwise an OLE-defined error code. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-createifelanguageinstance HRESULT CreateIFELanguageInstance( // [in] REFCLSID clsid, [out] VOID **ppvObj ); [UnmanagedFunctionPointer(CallingConvention.Winapi)] [PInvokeData("msime.h", MSDNShortId = "NF:msime.CreateIFELanguageInstance")] public delegate HRESULT CreateIFELanguageInstance([In, Optional] IntPtr clsid, out IFELanguage ppvObj); [PInvokeData("msime.h")] [UnmanagedFunctionPointer(CallingConvention.Winapi)] public delegate bool PFNLOG(ref IMEDP a, HRESULT hr); /// The information for each column [PInvokeData("msime.h")] [Flags] public enum FELANG_CLMN : uint { FELANG_CLMN_WBREAK = 0x01, FELANG_CLMN_NOWBREAK = 0x02, FELANG_CLMN_PBREAK = 0x04, FELANG_CLMN_NOPBREAK = 0x08, FELANG_CLMN_FIXR = 0x10, FELANG_CLMN_FIXD = 0x20, } /// Specifies the conversion output characters and conversion options. [PInvokeData("msime.h")] [Flags] public enum FELANG_CMODE : uint { /// Mono-ruby. FELANG_CMODE_MONORUBY = 0x00000002, /// No pruning. FELANG_CMODE_NOPRUNING = 0x00000004, /// Katakana output. FELANG_CMODE_KATAKANAOUT = 0x00000008, /// Default output. FELANG_CMODE_HIRAGANAOUT = 0x00000000, /// Half-width output. FELANG_CMODE_HALFWIDTHOUT = 0x00000010, /// Full-width output. FELANG_CMODE_FULLWIDTHOUT = 0x00000020, FELANG_CMODE_BOPOMOFO = 0x00000040, FELANG_CMODE_HANGUL = 0x00000080, FELANG_CMODE_PINYIN = 0x00000100, /// Do conversion as follows: FELANG_CMODE_PRECONV = 0x00000200, FELANG_CMODE_RADICAL = 0x00000400, FELANG_CMODE_UNKNOWNREADING = 0x00000800, /// Merge display with the same candidate. FELANG_CMODE_MERGECAND = 0x00001000, FELANG_CMODE_ROMAN = 0x00002000, /// Make only the first best. FELANG_CMODE_BESTFIRST = 0x00004000, /// Use invalid revword on REV/RECONV. FELANG_CMODE_USENOREVWORDS = 0x00008000, /// IME_SMODE_NONE FELANG_CMODE_NONE = 0x01000000, /// IME_SMODE_PLAURALCLAUSE FELANG_CMODE_PLAURALCLAUSE = 0x02000000, /// IME_SMODE_SINGLECONVERT FELANG_CMODE_SINGLECONVERT = 0x04000000, /// IME_SMODE_AUTOMATIC FELANG_CMODE_AUTOMATIC = 0x08000000, /// IME_SMODE_PHRASEPREDICT FELANG_CMODE_PHRASEPREDICT = 0x10000000, /// IME_SMODE_CONVERSATION FELANG_CMODE_CONVERSATION = 0x20000000, /// Name mode (MSKKIME). FELANG_CMODE_NAME = FELANG_CMODE_PHRASEPREDICT, /// Remove invisible chars (for example, the tone mark). FELANG_CMODE_NOINVISIBLECHAR = 0x40000000, } /// The conversion request. [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFELanguage")] public enum FELANG_REQ { FELANG_REQ_CONV = 0x00010000, FELANG_REQ_RECONV = 0x00020000, FELANG_REQ_REV = 0x00030000, } /// [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFEDictionary")] [Flags] public enum IFED_POS : uint { IFED_POS_NONE = 0x00000000, IFED_POS_NOUN = 0x00000001, IFED_POS_VERB = 0x00000002, IFED_POS_ADJECTIVE = 0x00000004, IFED_POS_ADJECTIVE_VERB = 0x00000008, IFED_POS_ADVERB = 0x00000010, IFED_POS_ADNOUN = 0x00000020, IFED_POS_CONJUNCTION = 0x00000040, IFED_POS_INTERJECTION = 0x00000080, IFED_POS_INDEPENDENT = 0x000000ff, IFED_POS_INFLECTIONALSUFFIX = 0x00000100, IFED_POS_PREFIX = 0x00000200, IFED_POS_SUFFIX = 0x00000400, IFED_POS_AFFIX = 0x00000600, IFED_POS_TANKANJI = 0x00000800, IFED_POS_IDIOMS = 0x00001000, IFED_POS_SYMBOLS = 0x00002000, IFED_POS_PARTICLE = 0x00004000, IFED_POS_AUXILIARY_VERB = 0x00008000, IFED_POS_SUB_VERB = 0x00010000, IFED_POS_DEPENDENT = 0x0001c000, IFED_POS_ALL = 0x0001ffff, } /// [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFEDictionary")] [Flags] public enum IFED_REG : uint { IFED_REG_NONE = 0x00000000, IFED_REG_USER = 0x00000001, IFED_REG_AUTO = 0x00000002, IFED_REG_GRAMMAR = 0x00000004, IFED_REG_ALL = 0x00000007, } /// [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFEDictionary")] [Flags] public enum IFED_SELECT : uint { IFED_SELECT_NONE = 0x00000000, IFED_SELECT_READING = 0x00000001, IFED_SELECT_DISPLAY = 0x00000002, IFED_SELECT_POS = 0x00000004, IFED_SELECT_COMMENT = 0x00000008, IFED_SELECT_ALL = 0x0000000f, } /// The dictionary type. [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFEDictionary")] [Flags] public enum IFED_TYPE : uint { /// Undefined. IFED_TYPE_NONE = 0x00000000, /// General dictionary. IFED_TYPE_GENERAL = 0x00000001, /// Name/place dictionary. IFED_TYPE_NAMEPLACE = 0x00000002, /// Speech dictionary. IFED_TYPE_SPEECH = 0x00000004, /// Reverse dictionary. IFED_TYPE_REVERSE = 0x00000008, /// English dictionary. IFED_TYPE_ENGLISH = 0x00000010, /// All of the above types. IFED_TYPE_ALL = 0x0000001f, } [PInvokeData("msime.h")] public enum IMEFMT { IFED_UNKNOWN, IFED_MSIME2_BIN_SYSTEM, IFED_MSIME2_BIN_USER, IFED_MSIME2_TEXT_USER, IFED_MSIME95_BIN_SYSTEM, IFED_MSIME95_BIN_USER, IFED_MSIME95_TEXT_USER, IFED_MSIME97_BIN_SYSTEM, IFED_MSIME97_BIN_USER, IFED_MSIME97_TEXT_USER, IFED_MSIME98_BIN_SYSTEM, IFED_MSIME98_BIN_USER, IFED_MSIME98_TEXT_USER, IFED_ACTIVE_DICT, IFED_ATOK9, IFED_ATOK10, IFED_NEC_AI_, IFED_WX_II, IFED_WX_III, IFED_VJE_20, IFED_MSIME98_SYSTEM_CE, IFED_MSIME_BIN_SYSTEM, IFED_MSIME_BIN_USER, IFED_MSIME_TEXT_USER, IFED_PIME2_BIN_USER, IFED_PIME2_BIN_SYSTEM, IFED_PIME2_BIN_STANDARD_SYSTEM, } [PInvokeData("msime.h")] public enum IMEREG { IFED_REG_HEAD, IFED_REG_TAIL, IFED_REG_DEL, } [PInvokeData("msime.h")] public enum IMEREL { IFED_REL_NONE, IFED_REL_NO, IFED_REL_GA, IFED_REL_WO, IFED_REL_NI, IFED_REL_DE, IFED_REL_YORI, IFED_REL_KARA, IFED_REL_MADE, IFED_REL_HE, IFED_REL_TO, IFED_REL_IDEOM, IFED_REL_FUKU_YOUGEN, //p2_1 IFED_REL_KEIYOU_YOUGEN, //p2_2 IFED_REL_KEIDOU1_YOUGEN, //p2_3 IFED_REL_KEIDOU2_YOUGEN, //p2_4 IFED_REL_TAIGEN, //p2_5 IFED_REL_YOUGEN, //p2_6 IFED_REL_RENTAI_MEI, //p3_1 IFED_REL_RENSOU, //p3_2 IFED_REL_KEIYOU_TO_YOUGEN, //p3_3 IFED_REL_KEIYOU_TARU_YOUGEN,//p3_4 IFED_REL_UNKNOWN1, //p3_5 IFED_REL_UNKNOWN2, //p3_6 IFED_REL_ALL, //any type } /// Type of user comment in a IMEWRD structure. // https://docs.microsoft.com/en-us/windows/win32/api/msime/ne-msime-imeuct typedef enum { IFED_UCT_NONE, IFED_UCT_STRING_SJIS, // IFED_UCT_STRING_UNICODE, IFED_UCT_USER_DEFINED, IFED_UCT_MAX } IMEUCT; [PInvokeData("msime.h", MSDNShortId = "NE:msime.__unnamed_enum_2")] public enum IMEUCT { IFED_UCT_NONE, IFED_UCT_STRING_SJIS, IFED_UCT_STRING_UNICODE, IFED_UCT_USER_DEFINED, IFED_UCT_MAX, } /// /// The IFECommon interface provides IME-related services that are common for different languages. /// IFECommon allows the developer to control very basic functions of IMEs. /// /// Create an instance of this interface with the CreateIFECommonInstance function. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nn-msime-ifecommon [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFECommon")] [ComImport, Guid("019F7151-E6DB-11d0-83C3-00C04FDDB82E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IFECommon { /// /// Determines if the IME specified by the class ID is the default IME on a local computer. /// The name of the IME is obtained from the Win32 keyboard layout API. /// /// The name of the IME for the specified class ID. Can be NULL. /// The size of szName in bytes. /// /// /// /// S_OK if this Microsoft IME is already the default IME. /// /// /// S_FALSE if this Microsoft IME is not the default IME. /// /// /// Otherwise E_FAIL. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifecommon-isdefaultime HRESULT IsDefaultIME( [out] const // CHAR *szName, [in] INT cszName ); [PreserveSig] HRESULT IsDefaultIME([Out, Optional, MarshalAs(UnmanagedType.LPStr)] StringBuilder szName, [In] int cszName); /// /// Allows the Microsoft IME to become the default IME in the keyboard layout. /// This method only applies when Microsoft IME uses the Input Method Manager(IMM) of the operating system. /// /// /// /// /// S_OK if successful. /// /// /// IFEC_S_ALREADY_DEFAULT if this Microsoft IME is already the default IME. /// /// /// Otherwise E_FAIL. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifecommon-setdefaultime HRESULT SetDefaultIME(); [PreserveSig] HRESULT SetDefaultIME(); /// Invokes the Microsoft IME Word Register Dialog Window from the app. /// Pointer to an IMEDLG structure. /// S_OK if successful, otherwise E_FAIL. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifecommon-invokewordregdialog HRESULT InvokeWordRegDialog( // [in] IMEDLG *pimedlg ); [PreserveSig] HRESULT InvokeWordRegDialog(in IMEDLG pimedlg); /// Invokes the Microsoft IME's Dictionary Tool from the app. /// Pointer to an IMEDLG structure. /// S_OK if successful, otherwise E_FAIL. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifecommon-invokedicttooldialog HRESULT InvokeDictToolDialog( // [in] IMEDLG *pimedlg ); [PreserveSig] HRESULT InvokeDictToolDialog(in IMEDLG pimedlg); } /// /// The IFEDictionary interface allows clients to access a Microsoft IME user dictionary. /// /// This API enables your apps to access and use the data contained in the Microsoft IME dictionaries(including personal name and /// geographical name dictionaries), or user dictionary.You can develop and sell such applications, provided that: /// /// /// You do not create an application that accesses a dictionary that is not a Microsoft IME dictionary through this API. /// /// You do not dump, copy, or distribute the dictionary data contained in the Microsoft IME. You must use this API only for the /// purpose of developing applications for users who already have the Microsoft IME. /// /// /// /// Create an instance of this interface with the CreateIFEDictionaryInstance function. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nn-msime-ifedictionary [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFEDictionary")] [ComImport, Guid("019F7153-E6DB-11d0-83C3-00C04FDDB82E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IFEDictionary { /// /// This method opens an existing dictionary file and associates it with this IFEDictionary object. To implement a multiple /// dictionary facility, multiple open and release procedures must be carried out. /// /// /// Points to a NULL-terminated file name string to be opened. If pchDictPath is NULL or an empty string, /// the user dictionary opened by the IME kernel will be used. If pchDictPath is an empty string, the name of user /// dictionary will be copied into pchDictPath, in which case the size of pchDictPath must be MAX_PATH. /// /// The IMESHF header of the opened file. Can be NULL. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-open HRESULT Open( [in, optional] CHAR // *pchDictPath, [out] IMESHF *pshf ); void Open([Optional, MarshalAs(UnmanagedType.LPStr)] string pchDictPath, out IMESHF pshf); /// This method closes the file associated to this IFEDictionary object. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-close HRESULT Close(); void Close(); /// Gets a dictionary header from a dictionary file without opening the dictionary. /// A NULL-terminated string containing the path and name of the dictionary file. /// The IMESHF header of the file. Can be NULL. /// /// The dictionary format. This can be one of the following values: /// /// IFED_UNKNOWN /// IFED_MSIME2_BIN_SYSTEM /// IFED_MSIME2_BIN_USER /// IFED_MSIME2_TEXT_USER /// IFED_MSIME95_BIN_SYSTEM /// IFED_MSIME95_BIN_USER /// IFED_MSIME95_TEXT_USER /// IFED_MSIME97_BIN_SYSTEM /// IFED_MSIME97_BIN_USER /// IFED_MSIME97_TEXT_USER /// IFED_MSIME98_BIN_SYSTEM /// IFED_MSIME98_BIN_USER /// IFED_MSIME98_TEST_USER /// IFED_ACTIVE_DICT /// IFED_ATOK9 /// IFED_ATOK10 /// IFED_NEC_AI_ /// IFED_WX_II /// IFED_WX_III /// IFED_VJE_20 /// IFED_MSIME98_SYSTEM_CE /// IFED_MSIME_BIN_SYSTEM /// IFED_MSIME_BIN_USER /// IFED_MSIME_TEXT_USER /// IFED_PIME2_BIN_USER /// IFED_PIME2_BIN_SYSTEM /// IFED_PIME2_BIN_STANDARD_SYSTEM /// /// /// /// The dictionary type. This is a combination of one or more of the following flags: /// /// /// Value /// Meaning /// /// /// IFED_TYPE_NONE /// Undefined. /// /// /// IFED_TYPE_GENERAL /// General dictionary. /// /// /// IFED_TYPE_NAMEPLACE /// Name/place dictionary. /// /// /// IFED_TYPE_SPEECH /// Speech dictionary. /// /// /// IFED_TYPE_REVERSE /// Reverse dictionary. /// /// /// IFED_TYPE_ENGLISH /// English dictionary. /// /// /// IFED_TYPE_ALL /// All of the above types. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-getheader HRESULT GetHeader( [in, out, // optional] CHAR *pchDictPath, [out] IMESHF *pshf, [out] IMEFMT *pjfmt, [out] ULONG *pulType ); void GetHeader([MarshalAs(UnmanagedType.LPStr)] StringBuilder pchDictPath, out IMESHF pshf, out IMEFMT pjfmt, out IFED_TYPE pulType); /// This method is obsolete starting with Windows 8, and is no longer supported. /// The parent window handle. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-displayproperty HRESULT DisplayProperty( [in] // HWND hwnd ); void DisplayProperty(HWND hwnd); /// Obtains the public POS (Part of Speech) table. /// Pointer to the array of POSTBL structures. /// Pointer to the number of POSTBL structures in the returned array. Can be NULL. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-getpostable HRESULT GetPosTable( [out] POSTBL // **prgPosTbl, [out] int *pcPosTbl ); void GetPosTable([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] out POSTBL[] prgPosTbl, out int pcPosTbl); /// /// The selection of a word entry can be performed by a combination of /// /// A string with Japanese phonetic characters, with or without a wildcard at the end of the string. /// A word, with or without a wildcard at its end. /// A Part of Speech /// /// /// In addition, retrievals by a string with Japanese phonetic characters can be performed by specifying a range in the Hiragana /// 50-on ordering. /// /// /// /// A text string against which IFEDictionary entries are matched; the value must be one of the following: /// /// /// Value /// Meaning /// /// /// NULL /// Low-value. /// /// /// /// Hiragana string (full text to be retrieved). /// /// /// /// /// Hiragana string ending in "*" (specifying only leading characters of text). This can be an initial text string when a range /// of words is to be retrieved, in which case a wildcard must not be used. /// /// /// /// /// /// /// A text string that is used to end a text string. This must contain the same value as pwchReading in the IMEWRD /// structure when a retrieval is performed by a single value; that is, not by a range value. The value must be one of the following: /// /// /// /// Value /// Meaning /// /// /// NULL /// High-value. /// /// /// /// Hiragana string (full text to be retrieved). /// /// /// /// Hiragana string ending in "*" (specifying only leading characters of text). /// /// /// /// /// A display string against which IFEDictionary entries are matched; the value must be one of the following: /// /// /// Value /// Meaning /// /// /// NULL /// Means "*". /// /// /// /// Any Japanese string. /// /// /// /// Japanese string ending in "*". /// /// /// /// /// Filter(s) on the Microsoft IME public Parts of Speech. This is a combination of one or more of the following flags: /// /// IFED_POS_NONE /// IFED_POS_NOUN /// IFED_POS_VERB /// IFED_POS_ADJECTIVE /// IFED_POS_ADJECTIVE_VERB /// IFED_POS_ADVERB /// IFED_POS_ADNOUN /// IFED_POS_CONJUNCTION /// IFED_POS_INTERJECTION /// IFED_POS_INDEPENDENT /// IFED_POS_INFLECTIONALSUFFIX /// IFED_POS_PREFIX /// IFED_POS_SUFFIX /// IFED_POS_AFFIX /// IFED_POS_TANKANJI /// IFED_POS_IDIOMS /// IFED_POS_SYMBOLS /// IFED_POS_PARTICLE /// IFED_POS_AUXILIARY_VERB /// IFED_POS_SUB_VERB /// IFED_POS_DEPENDENT /// IFED_POS_ALL /// /// /// /// Specifies the query output of a word. This is a combination of one or more of the following flags: /// /// IFED_SELECT_NONE /// IFED_SELECT_READING /// IFED_SELECT_DISPLAY /// IFED_SELECT_POS /// IFED_SELECT_COMMENT /// IFED_SELECT_ALL /// /// /// /// /// Specifies the word source. When the IFEDictionary is a user dictionary, this is a combination of one or more of the following flags: /// /// /// IFED_REG_NONE /// IFED_REG_USER /// IFED_REG_AUTO /// IFED_REG_GRAMMAR /// IFED_REG_ALL /// /// /// Buffer provided by the caller to receive the data. /// The size of pchBuffer. /// /// The number of IMEWRD structures returned in pchBuffer. If more entries are found than pchBuffer can store, /// IFED_S_MORE_ENTRIES will be returned. /// /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// /// /// /// IFED_S_MORE_ENTRIES /// The client must call NextWords to get additional IMEWRD structures. /// /// /// IFED_E_NO_ENTRY /// /// /// /// E_OUTOFMEMORY /// /// /// /// E_FAIL /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-getwords HRESULT GetWords( [in] const WCHAR // *pwchFirst, [in] const WCHAR *pwchLast, [in] const WCHAR *pwchDisplay, [in] ULONG ulPos, [in] ULONG ulSelect, [in] ULONG // ulWordSrc, [in, out] UCHAR *pchBuffer, [in] ULONG cbBuffer, [out] ULONG *pcWrd ); [PreserveSig] HRESULT GetWords([MarshalAs(UnmanagedType.LPWStr)] string pwchFirst, [MarshalAs(UnmanagedType.LPWStr)] string pwchLast, [MarshalAs(UnmanagedType.LPWStr)] string pwchDisplay, IFED_POS ulPos, IFED_SELECT ulSelect, IFED_REG ulWordSrc, IntPtr pchBuffer, uint cbBuffer, out uint pcWrd); /// This method is used only after GetWords to get additional words. /// Buffer provided by the caller to receive the data. /// The size of pchBuffer. /// /// The number of IMEWRD structures returned in pchBuffer. If more entries are found than pchBuffer can store, /// IFED_S_MORE_ENTRIES will be returned. /// /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// /// /// /// IFED_S_MORE_ENTRIES /// The client must call NextWords to get additional IMEWRD structures. /// /// /// E_FAIL /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-nextwords HRESULT NextWords( [in, out] UCHAR // *pchBuffer, [in] ULONG cbBuffer, [out] ULONG *pcWrd ); [PreserveSig] HRESULT NextWords(IntPtr pchBuffer, uint cbBuffer, out uint pcWrd); /// Creates a new dictionary file. /// /// A NULL-terminated string containing the path and name for the new dictionary file to be created. /// /// The IMESHF header for the new dictionary. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-create HRESULT Create( [in] const CHAR // *pchDictPath, [in] IMESHF *pshf ); void Create([MarshalAs(UnmanagedType.LPStr)] string pchDictPath, in IMESHF pshf); /// This method sets or modifies the dictionary header of this IFEDictionary object. /// The IMESHF header to set. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-setheader HRESULT SetHeader( [in] IMESHF *pshf ); void SetHeader(in IMESHF pshf); /// Determines if the specified word exists in IFEDictionary. /// An IMEWRD structure specifying the word to check. /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The word exists. /// /// /// S_FALSE /// The word does not exist. /// /// /// E_FAIL /// An unexpected error. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-existword HRESULT ExistWord( [in] IMEWRD *pwrd ); [PreserveSig] HRESULT ExistWord(in IMEWRD pwrd); /// See if dependency pair exist in dictionary /// The dependency pair. /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The pair exists. /// /// /// S_FALSE /// The pair does not exist. /// /// /// E_FAIL /// An unexpected error. /// /// /// [PreserveSig] HRESULT ExistDependency(in IMEDP pdp); /// Registers a new word or deletes an existing word in the IFEDictionary. /// /// Type of operation to perform. This can be one of the following values: /// /// /// Value /// Meaning /// /// /// IFED_REG_HEAD /// Register the word at the head of the dictionary. /// /// /// IFED_REG_TAIL /// Register the word at the tail of the dictionary. /// /// /// IFED_REG_DEL /// Delete the word from the dictionary. /// /// /// /// An IMEWRD structure specifying the word to register or delete. /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The method was successful. /// /// /// IFED_E_NOT_USER_DIC /// This IFEDictionary object is not a user dictionary. /// /// /// IFED_S_WORD_EXISTS /// The word is already registered. /// /// /// IFED_E_USER_COMMENT /// Failed to insert the user comment. /// /// /// S_FALSE /// Failed to register or delete the word. /// /// /// E_FAIL /// An unexpected error. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-registerword HRESULT RegisterWord( [in] IMEREG // reg, [in] IMEWRD *pwrd ); [PreserveSig] HRESULT RegisterWord(IMEREG reg, in IMEWRD pwrd); /// Registers a new dependency or deletes an existing dependency in the IFEDictionary. /// /// Type of operation to perform. This can be one of the following values: /// /// /// Value /// Meaning /// /// /// IFED_REG_HEAD /// Register the dependency at the head of the dictionary. /// /// /// IFED_REG_TAIL /// Register the dependency at the tail of the dictionary. /// /// /// IFED_REG_DEL /// Delete the dependency from the dictionary. /// /// /// /// An IMEDP structure specifying the dependency to register or delete. /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// The method was successful. /// /// /// IFED_E_NOT_USER_DIC /// This IFEDictionary object is not a user dictionary. /// /// /// IFED_S_WORD_EXISTS /// The dependency is already registered. /// /// /// IFED_E_USER_COMMENT /// Failed to insert the user comment. /// /// /// S_FALSE /// Failed to register or delete the dependency. /// /// /// E_FAIL /// An unexpected error. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifedictionary-registerword HRESULT RegisterWord( [in] IMEREG // reg, [in] IMEWRD *pwrd ); [PreserveSig] HRESULT RegisterDependency(IMEREG reg, in IMEDP pdp); /// Undocumented /// The kakarigo reading. /// The kakarigo display. /// The part of speech for kakarigo. /// The ukego reading. /// The ukego display. /// The part of speech for uke. /// The relation type. /// /// /// Specifies the word source. When the IFEDictionary is a user dictionary, this is a combination of one or more of the following flags: /// /// /// IFED_REG_NONE /// IFED_REG_USER /// IFED_REG_AUTO /// IFED_REG_GRAMMAR /// IFED_REG_ALL /// /// /// Buffer provided by the caller to receive the data. /// The size of pchBuffer. /// /// The number of IMEDP structures returned in pchBuffer. If more entries are found than pchBuffer can store, /// IFED_S_MORE_ENTRIES will be returned. /// /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// /// /// /// IFED_S_MORE_ENTRIES /// The client must call NextWords to get additional IMEDP structures. /// /// /// IFED_E_NO_ENTRY /// /// /// /// E_OUTOFMEMORY /// /// /// /// E_FAIL /// /// /// /// [PreserveSig] HRESULT GetDependencies([MarshalAs(UnmanagedType.LPWStr)] string pwchKakariReading, [MarshalAs(UnmanagedType.LPWStr)] string pwchKakariDisplay, uint ulKakariPos, [MarshalAs(UnmanagedType.LPWStr)] string pwchUkeReading, [MarshalAs(UnmanagedType.LPWStr)] string pwchUkeDisplay, uint ulUkePos, IMEREL jrel, IFED_REG ulWordSrc, IntPtr pchBuffer, uint cbBuffer, out uint pcdp); /// This method is used only after GetWords to get additional dependencies. /// Buffer provided by the caller to receive the data. /// The size of pchBuffer. /// /// The number of IMEDP structures returned in pchBuffer. If more entries are found than pchBuffer can store, /// IFED_S_MORE_ENTRIES will be returned. /// /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// /// /// /// IFED_S_MORE_ENTRIES /// The client must call NextWords to get additional IMEDP structures. /// /// /// E_FAIL /// /// /// /// [PreserveSig] HRESULT NextDependencies(IntPtr pchBuffer, uint cbBuffer, out uint pcdp); /// Undocumented /// old ime user dictionary path /// pointer to log function /// word registration info /// [PreserveSig] HRESULT ConvertFromOldMSIME([MarshalAs(UnmanagedType.LPStr)] string pchDic, PFNLOG pfnLog, IMEREG reg); /// Undocumented /// [PreserveSig] HRESULT ConvertFromUserToSys(); } /// The IFELanguage interface provides language processing services using the Microsoft IME. /// Create an instance of this interface with the CreateIFELanguageInstance function. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nn-msime-ifelanguage [PInvokeData("msime.h", MSDNShortId = "NN:msime.IFELanguage")] [ComImport, Guid("019F7152-E6DB-11d0-83C3-00C04FDDB82E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IFELanguage { /// This method must be called before any use of the IFELanguage object. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifelanguage-open HRESULT Open(); void Open(); /// This method must be called after your last use of the IFELanguage object. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifelanguage-close HRESULT Close(); void Close(); /// Gets morphological analysis results. /// /// The conversion request. It can be one of the following values: /// FELANG_REQ_CONV /// FELANG_REQ_RECONV /// FELANG_REQ_REV /// /// /// /// Specifies the conversion output characters and conversion options. This value is a combination of one or more of the /// following flags: /// /// /// /// Value /// Meaning /// /// /// FELANG_CMODE_MONORUBY /// Mono-ruby. /// /// /// FELANG_CMODE_NOPRUNING /// No pruning. /// /// /// FELANG_CMODE_KATAKANAOUT /// Katakana output. /// /// /// FELANG_CMODE_HIRAGANAOUT /// Default output. /// /// /// FELANG_CMODE_HALFWIDTHOUT /// Half-width output. /// /// /// FELANG_CMODE_FULLWIDTHOUT /// Full-width output. /// /// /// FELANG_CMODE_BOPOMOFO /// /// /// /// FELANG_CMODE_HANGUL /// /// /// /// FELANG_CMODE_PINYIN /// /// /// /// FELANG_CMODE_PRECONV /// Do conversion as follows: /// /// /// FELANG_CMODE_RADICAL /// /// /// /// FELANG_CMODE_UNKNOWNREADING /// /// /// /// FELANG_CMODE_MERGECAND /// Merge display with the same candidate. /// /// /// FELANG_CMODE_ROMAN /// /// /// /// FELANG_CMODE_BESTFIRST /// Make only the first best. /// /// /// FELANG_CMODE_USENOREVWORDS /// Use invalid revword on REV/RECONV. /// /// /// FELANG_CMODE_NONE /// IME_SMODE_NONE /// /// /// FELANG_CMODE_PLAURALCLAUSE /// IME_SMODE_PLAURALCLAUSE /// /// /// FELANG_CMODE_SINGLECONVERT /// IME_SMODE_SINGLECONVERT /// /// /// FELANG_CMODE_AUTOMATIC /// IME_SMODE_AUTOMATIC /// /// /// FELANG_CMODE_PHRASEPREDICT /// IME_SMODE_PHRASEPREDICT /// /// /// FELANG_CMODE_CONVERSATION /// IME_SMODE_CONVERSATION /// /// /// FELANG_CMODE_NAME /// Name mode (MSKKIME). /// /// /// FELANG_CMODE_NOINVISIBLECHAR /// Remove invisible chars (for example, the tone mark). /// /// /// /// The number of characters in pwchInput. /// /// Input characters to be converted by the morphology engine. This must be a UNICODE string. /// /// Set this parameter to NULL to get the next entry for the previously input string, with the next rank. The order in /// which next entries are returned is defined by the implementation. /// /// /// /// /// The information for each column, where each pfCInfo[x] corresponds to pwchInput[x]. Each DWORD can be a /// combination of the flags below: /// /// FELANG_CLMN_WBREAK /// FELANG_CLMN_NOWBREAK /// FELANG_CLMN_PBREAK /// FELANG_CLMN_NOPBREAK /// FELANG_CLMN_FIXR /// FELANG_CLMN_FIXD /// /// /// The address of a MORRSLT structure that receives the morphology result data. /// /// GetJMorphResult allocates memory using the OLE task allocator for the returned data, and sets the pResult to /// point to the memory. The application must free the memory pointed to by pResult, by using the CoTaskMemFree. /// /// /// /// This method can return one of these values. /// /// /// Return code /// Description /// /// /// S_OK /// /// More candidates exist. If you call this function again with pwchInput equal to NULL, it will get the next best /// candidate for the previous pwchInput. /// /// /// /// S_FALSE /// No result. /// /// /// E_NOCAND /// No more candidates. /// /// /// E_LARGEINPUT /// input too large. /// /// /// ERROR_SEM_TIMEOUT /// Mutex timeout is occurred. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifelanguage-getjmorphresult HRESULT GetJMorphResult( [in] // DWORD dwRequest, [in] DWORD dwCMode, [in] INT cwchInput, [in] const WCHAR *pwchInput, [in] DWORD *pfCInfo, [out] MORRSLT // **ppResult ); [PreserveSig] HRESULT GetJMorphResult(FELANG_REQ dwRequest, FELANG_CMODE dwCMode, int cwchInput, [MarshalAs(UnmanagedType.LPWStr)] string pwchInput, [MarshalAs(UnmanagedType.LPArray)] FELANG_CLMN[] pfCInfo, out SafeCoTaskMemStruct ppResult); /// Gets the conversion mode capability of the IFELanguage object. /// /// The capabilities, represented as a combination of one or more of the following flags: /// /// /// Value /// Meaning /// /// /// FELANG_CMODE_MONORUBY /// Mono-ruby. /// /// /// FELANG_CMODE_NOPRUNING /// No pruning. /// /// /// FELANG_CMODE_KATAKANAOUT /// Katakana output. /// /// /// FELANG_CMODE_HIRAGANAOUT /// Default output. /// /// /// FELANG_CMODE_HALFWIDTHOUT /// Half-width output. /// /// /// FELANG_CMODE_FULLWIDTHOUT /// Full-width output. /// /// /// FELANG_CMODE_BOPOMOFO /// /// /// /// FELANG_CMODE_HANGUL /// /// /// /// FELANG_CMODE_PINYIN /// /// /// /// FELANG_CMODE_PRECONV /// Do conversion as follows: /// /// /// FELANG_CMODE_RADICAL /// /// /// /// FELANG_CMODE_UNKNOWNREADING /// /// /// /// FELANG_CMODE_MERGECAND /// Merge display with the same candidate. /// /// /// FELANG_CMODE_ROMAN /// /// /// /// FELANG_CMODE_BESTFIRST /// Make only the first best. /// /// /// FELANG_CMODE_USENOREVWORDS /// Use invalid revword on REV/RECONV. /// /// /// FELANG_CMODE_NONE /// IME_SMODE_NONE /// /// /// FELANG_CMODE_PLAURALCLAUSE /// IME_SMODE_PLAURALCLAUSE /// /// /// FELANG_CMODE_SINGLECONVERT /// IME_SMODE_SINGLECONVERT /// /// /// FELANG_CMODE_AUTOMATIC /// IME_SMODE_AUTOMATIC /// /// /// FELANG_CMODE_PHRASEPREDICT /// IME_SMODE_PHRASEPREDICT /// /// /// FELANG_CMODE_CONVERSATION /// IME_SMODE_CONVERSATION /// /// /// FELANG_CMODE_NAME /// Name mode (MSKKIME). /// /// /// FELANG_CMODE_NOINVISIBLECHAR /// Remove invisible chars (for example, the tone mark). /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifelanguage-getconversionmodecaps HRESULT // GetConversionModeCaps( [out] DWORD *pdwCaps ); void GetConversionModeCaps(out FELANG_CMODE pdwCaps); void GetPhonetic([MarshalAs(UnmanagedType.BStr)] string @string, int start, int length, [MarshalAs(UnmanagedType.BStr)] out string phonetic); /// Converts the input string (which usually contains the Hiragana character) to converted strings. /// A string of phonetic characters to convert. /// /// The starting character from which IFELanguage begins conversion. The first character of string is represented by 1 /// (not 0). /// /// /// The number of characters to convert. If this value is -1, all of the remaining characters from start are converted. /// /// The converted string. This string is allocated by SysAllocStringLen and must be freed by the client. // https://docs.microsoft.com/en-us/windows/win32/api/msime/nf-msime-ifelanguage-getconversion HRESULT GetConversion( [in] BSTR // string, [in] LONG start, [in] LONG length, [out, retval] BSTR *result ); void GetConversion([MarshalAs(UnmanagedType.BStr)] string @string, int start, int length, [MarshalAs(UnmanagedType.BStr)] out string result); } /// Used when invoking the Microsoft IME's Dictionary Tool or Word Register Dialog Window from the app. // https://docs.microsoft.com/en-us/windows/win32/api/msime/ns-msime-imedlg typedef struct _IMEDLG { int cbIMEDLG; HWND hwnd; LPWSTR // lpwstrWord; int nTabId; } IMEDLG; [PInvokeData("msime.h", MSDNShortId = "NS:msime._IMEDLG")] [StructLayout(LayoutKind.Sequential)] public struct IMEDLG { /// The size of this structure. You must set this value before using the structure. public int cbIMEDLG; /// The parent window handle of the Register Word Dialog. public HWND hwnd; /// , or the string to be registered. It shows in the Word Register Dialog's "Display" field. [MarshalAs(UnmanagedType.LPWStr)] public string lpwstrWord; /// The initial tab ID, 0 or 1. public int nTabId; /// Initializes a new instance of the struct. /// The parent window handle of the Register Word Dialog. /// /// , or the string to be registered. It shows in the Word Register Dialog's "Display" field. /// /// The initial tab ID, 0 or 1. public IMEDLG(HWND hwnd, string display = null, int tabId = 0) { cbIMEDLG = Marshal.SizeOf(typeof(IMEDLG)); this.hwnd = hwnd; lpwstrWord = display; nTabId = tabId; } } [PInvokeData("msime.h")] [StructLayout(LayoutKind.Sequential)] public struct IMEDP { public IMEWRD wrdModifier; //kakari-go public IMEWRD wrdModifiee; //uke-go public IMEREL relID; } /// /// The header of an opened user dictionary file. Used to get the user dictionary's properties, such as version, title, description, /// and copyright. /// // https://docs.microsoft.com/en-us/windows/win32/api/msime/ns-msime-imeshf typedef struct _IMESHF { WORD cbShf; WORD verDic; CHAR // szTitle[48]; CHAR szDescription[256]; CHAR szCopyright[128]; } IMESHF; [PInvokeData("msime.h", MSDNShortId = "NS:msime._IMESHF")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct IMESHF { /// The size of this structure. You must set this value before using the structure. public ushort cbShf; /// Dictionary version. public ushort verDic; /// Dictionary title. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)] public string szTitle; /// Dictionary description. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string szDescription; /// Dictionary copyright information. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string szCopyright; } /// Contains data about a word in the Word data of the Microsoft IME dictionary. // https://docs.microsoft.com/en-us/windows/win32/api/msime/ns-msime-imewrd typedef struct _IMEWRD { WCHAR *pwchReading; WCHAR // *pwchDisplay; union { ULONG ulPos; struct { WORD nPos1; WORD nPos2; }; }; ULONG rgulAttrs[2]; INT cbComment; IMEUCT uct; VOID // *pvComment; } IMEWRD, *PIMEWRD; [PInvokeData("msime.h", MSDNShortId = "NS:msime._IMEWRD")] [StructLayout(LayoutKind.Sequential)] public struct IMEWRD { /// The reading string. [MarshalAs(UnmanagedType.LPWStr)] public string pwchReading; /// The display string. [MarshalAs(UnmanagedType.LPWStr)] public string pwchDisplay; /// POS (Part of Speech), defined as JPOS_***. public uint ulPos; /// Reserved. public ulong rgulAttrs; /// Size of the comment, in bytes, of pvComment. public int cbComment; /// Type of comment. This must be one of the values of the IMEUCT enumeration. public IMEUCT uct; /// Comment string. public IntPtr pvComment; } /// Undocumented. [PInvokeData("msime.h")] [StructLayout(LayoutKind.Sequential)] public struct MORRSLT { /// total size of this block. public uint dwSize; /// conversion result string. [MarshalAs(UnmanagedType.LPWStr)] public string pwchOutput; /// lengh of result string. public ushort cchOutput; /// reading string [MarshalAs(UnmanagedType.LPWStr)] public string pwchRead; /// length of reading string. public ushort cchRead; /// index array of reading to input character. public IntPtr pchInputPos; /// index array of output character to WDD public IntPtr pchOutputIdxWDD; /// index array of reading character to WDD public IntPtr pchReadIdxWDD; /// array of position of monoruby public IntPtr paMonoRubyPos; /// pointer to array of WDD public IntPtr pWDD; /// number of WDD public int cWDD; /// pointer of private data area public IntPtr pPrivate; /// /// area for stored above members. /// ushort wchOutput[cchOutput]; /// ushort wchRead[cchRead]; /// sbyte chInputIdx[cwchInput]; /// sbyte chOutputIdx[cchOutput]; /// sbyte chReadIndx[cchRead]; /// ???? Private /// WDD WDDBlk[cWDD]; /// public IntPtr BLKBuff; } /// An entry in the public POS (Part of Speech) table. // https://docs.microsoft.com/en-us/windows/win32/api/msime/ns-msime-postbl typedef struct _POSTBL { WORD nPos; BYTE *szName; } POSTBL; [PInvokeData("msime.h", MSDNShortId = "NS:msime._POSTBL")] [StructLayout(LayoutKind.Sequential)] public struct POSTBL { /// The number of the part of speech. public ushort nPos; /// The name of the part of speech. public IntPtr szName; } /* // Word Descriptor public struct WDD { WORD wDispPos; // Offset of Output string union { WORD wReadPos; // Offset of Reading string WORD wCompPos; }; WORD cchDisp; //number of ptchDisp union { WORD cchRead; //number of ptchRead WORD cchComp; }; DWORD WDD_nReserve1; //reserved WORD nPos; //part of speech // implementation-defined WORD fPhrase : 1;//start of phrase WORD fAutoCorrect: 1;//auto-corrected WORD fNumericPrefix: 1;//kansu-shi expansion(JPN) WORD fUserRegistered: 1;//from user dictionary WORD fUnknown: 1;//unknown word (duplicated information with nPos.) WORD fRecentUsed: 1; //used recently flag WORD :10; // VOID *pReserved; //points directly to WORDITEM } */ } }