Example #1
0
        public static bool CheckMaxValue(string value, out string retString, LWRegistryValueKind regDataType)
        {
            retString = value;

            switch (regDataType)
            {
            case LWRegistryValueKind.REG_DWORD:
                if (UInt64.Parse(value) > UInt32.MaxValue)
                {
                    string       sMsg    = "The decimal value entered is greater than the maximum value of a DWORD. \n Should the value be truncated in order to continue?";
                    DialogResult dResult = MessageBox.Show(sMsg, "Overflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dResult == DialogResult.Yes)
                    {
                        retString = UInt32.MaxValue.ToString();
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;

            case LWRegistryValueKind.REG_QUADWORD:
                if (double.Parse(value) > UInt64.MaxValue)
                {
                    string       sMsg    = "The decimal value entered is greater than the maximum value of a DWORD. \n Should the value be truncated in order to continue?";
                    DialogResult dResult = MessageBox.Show(sMsg, "Overflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dResult == DialogResult.Yes)
                    {
                        retString = UInt64.MaxValue.ToString();
                    }
                    else
                    {
                        return(false);
                    }
                }
                break;
            }
            return(true);
        }
        public static bool CheckMaxValue(string value, out string retString, LWRegistryValueKind regDataType)
        {
            retString = value;

            switch (regDataType)
            {
                case LWRegistryValueKind.REG_DWORD:
                    if (UInt64.Parse(value) > UInt32.MaxValue)
                    {
                        string sMsg = "The decimal value entered is greater than the maximum value of a DWORD. \n Should the value be truncated in order to continue?";
                        DialogResult dResult = MessageBox.Show(sMsg, "Overflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dResult == DialogResult.Yes)
                            retString = UInt32.MaxValue.ToString();
                        else
                            return false;
                    }
                    break;

                case LWRegistryValueKind.REG_QUADWORD:
                    if (double.Parse(value) > UInt64.MaxValue)
                    {
                        string sMsg = "The decimal value entered is greater than the maximum value of a DWORD. \n Should the value be truncated in order to continue?";
                        DialogResult dResult = MessageBox.Show(sMsg, "Overflow", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (dResult == DialogResult.Yes)
                            retString = UInt64.MaxValue.ToString();
                        else
                            return false;
                    }
                    break;
            }
            return true;
        }
        private string GetRegValueStringType(LWRegistryValueKind valuekind)
        {
            string sRegType = string.Empty;

            switch (valuekind)
            {
                case LWRegistryValueKind.REG_BINARY:
                    sRegType = "REG_BINARY";
                    break;

                case LWRegistryValueKind.REG_DWORD:
                    sRegType = "REG_DWORD";
                    break;

                case LWRegistryValueKind.REG_EXPAND_SZ:
                    sRegType = "REG_EXPAND_SZ";
                    break;

                case LWRegistryValueKind.REG_MULTI_SZ:
                    sRegType = "REG_MULTI_SZ";
                    break;

                case LWRegistryValueKind.REG_NONE:
                    sRegType = "REG_NONE";
                    break;

                case LWRegistryValueKind.REG_QUADWORD:
                    sRegType = "REG_QWORD";
                    break;

                case LWRegistryValueKind.REG_RESOURCE_LIST:
                    sRegType = "REG_RESOURCE_LIST";
                    break;

                case LWRegistryValueKind.REG_SZ:
                    sRegType = "REG_SZ";
                    break;

                default :
                    sRegType = "REG_SZ";
                    break;
            }

            return sRegType;
        }