public static string MB_GetString(SystemLocStrings btnId) { StringBuilder sb = new StringBuilder(256); if (_user32 == IntPtr.Zero) { _user32 = LoadLibrary(Path.Combine(Environment.SystemDirectory, "User32.dll")); } int length = LoadString(_user32, (uint)btnId, sb, sb.Capacity); if (length == 0 || sb.Length == 0) { return(btnId.ToString()); } return(sb.ToString().Replace('&', '_')); }
static MessageBoxForm() { if (s_buttons == null) s_buttons = new DialogResult[][] { new DialogResult[] { DialogResult.OK }, new DialogResult[] { DialogResult.OK, DialogResult.Cancel }, new DialogResult[] { DialogResult.Abort, DialogResult.Retry, DialogResult.Ignore }, new DialogResult[] { DialogResult.Yes, DialogResult.No, DialogResult.Cancel }, new DialogResult[] { DialogResult.Yes, DialogResult.No }, new DialogResult[] { DialogResult.Retry, DialogResult.Cancel } }; if (s_buttonLocIDs == null) { SystemLocStrings[] stringsArray = new SystemLocStrings[8]; stringsArray[0] = SystemLocStrings.Close; stringsArray[2] = SystemLocStrings.Cancel; stringsArray[3] = SystemLocStrings.Abort; stringsArray[4] = SystemLocStrings.Retry; stringsArray[5] = SystemLocStrings.Ignore; stringsArray[6] = SystemLocStrings.Yes; stringsArray[7] = SystemLocStrings.No; s_buttonLocIDs = stringsArray; } }