예제 #1
0
        public static bool CheckDuplicateValue(object parentKey, string valueName)
        {
            RegistryKey sParentKey = parentKey as RegistryKey;
            bool        retValue   = RegistryInteropWrapperWindows.Win32CheckDuplicateValue(sParentKey, valueName);

            if (retValue)
            {
                string sMsg = "The LAC cannot rename the Value. The specified value name already exists. Type another name and try again.";
                MessageBox.Show(sMsg, "Error Renaming Value", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(retValue);
        }
예제 #2
0
        public static bool CheckDuplicateKey(object parentKey, string subKeyName)
        {
            if (subKeyName.Contains("\\"))
            {
                string sMsg = "The LAC cannot rename the key. Specify a key name without (\\).";
                MessageBox.Show(sMsg, "Error Renaming Key", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(true);
            }

            bool retValue = RegistryInteropWrapperWindows.Win32CheckDuplicateKey(parentKey, subKeyName);

            if (retValue)
            {
                string sMsg = "The LAC cannot rename the key. The specified Key name already exists. Type another name and try again.";
                MessageBox.Show(sMsg, "Error Renaming Key", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(retValue);
        }
예제 #3
0
        public static object GetFormatSpecificData(SubKeyValueInfo valueInfo)
        {
            object sData = null;

            switch (valueInfo.RegDataType)
            {
            case LWRegistryValueKind.REG_BINARY:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                byte[] byts = valueInfo.sDataBuf as byte[];
                sData = GetBinaryData(byts);
                break;

            case LWRegistryValueKind.REG_DWORD:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = RegistryUtils.DecimalToBase((UInt32)Convert.ToInt32(valueInfo.sDataBuf), 16).PadLeft(8, '0');
                break;

            case LWRegistryValueKind.REG_EXPAND_SZ:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                byte[]      eByts    = new ASCIIEncoding().GetBytes(valueInfo.sDataBuf.ToString() + "\r\n");
                List <byte> eBytList = new List <byte>();
                foreach (byte byt in eByts)
                {
                    if (byt == 10 || byt == 13)
                    {
                        eBytList.Add((byte)00);
                    }
                    else
                    {
                        eBytList.Add(byt);
                        eBytList.Add((byte)00);
                    }
                }
                eByts = new byte[eBytList.Count];
                eBytList.CopyTo(eByts);
                sData = GetBinaryData(eByts);
                break;

            case LWRegistryValueKind.REG_SZ:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = string.Concat("\"", valueInfo.sDataBuf, "\"");
                break;

            case LWRegistryValueKind.REG_MULTI_SZ:
                string[]      sDataArry = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames) as string[];
                StringBuilder sTempArry = new StringBuilder();
                List <byte>   bytList   = new List <byte>();
                foreach (string value in sDataArry)
                {
                    sTempArry.AppendLine(value);
                }
                byte[] sByts = new ASCIIEncoding().GetBytes(sTempArry.ToString() + "\r\n");
                foreach (byte byt in sByts)
                {
                    if (byt == 10 || byt == 13)
                    {
                        bytList.Add((byte)00);
                    }
                    else
                    {
                        bytList.Add(byt);
                        bytList.Add((byte)00);
                    }
                }
                sByts = new byte[bytList.Count];
                bytList.CopyTo(sByts);
                sData = GetBinaryData(sByts);
                break;

            case LWRegistryValueKind.REG_QUADWORD:
                valueInfo.sDataBuf = valueInfo.sParentKey.GetValue(valueInfo.sValue, null, RegistryValueOptions.DoNotExpandEnvironmentNames);
                sData = RegistryUtils.DecimalToBase((UInt64)Convert.ToUInt32(valueInfo.sDataBuf), 16).PadLeft(16, '0');
                break;

            case LWRegistryValueKind.REG_RESOURCE_LIST:
            case LWRegistryValueKind.REG_UNKNOWN:
                string[] sKey        = valueInfo.sParentKey.ToString().Split(new char[] { '\\' }, 2);
                object   data        = RegistryInteropWrapperWindows.RegGetValue(RegistryInteropWrapperWindows.GetRegistryHive(valueInfo.hKey), sKey[1], valueInfo.sValue, out valueInfo.intDataType);
                byte[]   bBinarydata = data as byte[];
                sData = GetBinaryData(bBinarydata);
                break;

            default:
                break;
            }
            return(sData);
        }