Example #1
0
 private static string GetString(GetStringDisplayMethod method, string localeId, string displayLocaleId)
 {
     return(NativeMethods.GetUnicodeString((ptr, length) =>
     {
         length = method(localeId, displayLocaleId, ptr, length, out var err);
         return new Tuple <ErrorCode, int>(err, length);
     }));
 }
Example #2
0
        private static string GetString(GetStringDisplayMethod method, string localeId, string displayLocaleId)
        {
            const int nSize  = 255;
            IntPtr    resPtr = Marshal.AllocCoTaskMem(nSize * 2);

            try
            {
                ErrorCode err;
                method(localeId, displayLocaleId, resPtr, nSize, out err);
                if (!Failure(err))
                {
                    return(Marshal.PtrToStringUni(resPtr));
                }
                return(string.Empty);
            }
            finally
            {
                Marshal.FreeCoTaskMem(resPtr);
            }
        }