private yepLibrary_GetString ( Enumeration enumeration, uint value, StringType stringType, System buffer, System &length ) : Status | ||
enumeration | Enumeration | |
value | uint | |
stringType | StringType | |
buffer | System | |
length | System | |
리턴 | Status |
internal static bool IsDefined(Enumeration enumeration, uint value) { System.UIntPtr length = System.UIntPtr.Zero; Status status = Library.yepLibrary_GetString(enumeration, value, StringType.Description, System.IntPtr.Zero, ref length); return(status == Status.InsufficientBuffer); }
internal static string GetString(Enumeration enumeration, uint value, StringType stringType) { System.UIntPtr length = System.UIntPtr.Zero; Status status = Library.yepLibrary_GetString(enumeration, value, stringType, System.IntPtr.Zero, ref length); if (status != Status.InsufficientBuffer) { throw new System.SystemException(); } int smallLength = checked ((int)length); System.IntPtr unmanagedBuffer = Marshal.AllocHGlobal(smallLength); try { status = yepLibrary_GetString(enumeration, value, stringType, unmanagedBuffer, ref length); if (status != Status.Ok) { throw new System.SystemException(); } byte[] managedBuffer = new byte[smallLength]; Marshal.Copy(unmanagedBuffer, managedBuffer, 0, smallLength); return(System.Text.Encoding.UTF8.GetString(managedBuffer)); } finally { Marshal.FreeHGlobal(unmanagedBuffer); } }