Ejemplo n.º 1
0
        protected void GenerateRegTextFileInternal(TreeNode node, TextWriter writer)
        {
            bool writeKey = true;

            foreach (TreeNode item in node.Nodes)
            {
                Model.RegInfo regInfo = item.Tag as Model.RegInfo;
                if (regInfo == null)
                {
                    GenerateRegTextFileInternal(item, writer);
                }
                else
                {
                    if (writeKey)
                    {
                        writer.WriteLine();

                        string regKey;
                        string tempRegKey = node.FullPath;
                        if (tempRegKey.IndexOf(HKLM_SHORT, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            regKey = string.Format("[{0}{1}]", HKLM_LONG, tempRegKey.Substring(HKLM_SHORT.Length));
                        }
                        else if (tempRegKey.IndexOf(HKCU_SHORT, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            regKey = string.Format("[{0}{1}]", HKCU_LONG, tempRegKey.Substring(HKCU_SHORT.Length));
                        }
                        else
                        {
                            regKey = string.Format("[{0}]", tempRegKey);
                        }
                        writer.WriteLine(regKey);
                        writeKey = false;
                    }
                    string regKind;
                    string regValue;
                    GetRegFileValue(regInfo, out regKind, out regValue);
                    if (regInfo.ValueName == "@")
                    {
                        if (!string.IsNullOrWhiteSpace(regValue))
                        {
                            writer.WriteLine("{0}={1}{2}", regInfo.ValueName, regKind, regValue);
                        }
                    }
                    else
                    {
                        writer.WriteLine("\"{0}\"={1}{2}", regInfo.ValueName, regKind, regValue);
                    }
                }
            }
        }
        private static void SearchandReplaceInternal(this TreeNode pThis, string searchStr, string replaceStr)
        {
            if (pThis.Nodes != null && pThis.Nodes.Count > 0)
            {
                foreach (TreeNode item in pThis.Nodes)
                {
                    SearchandReplaceInternal(item, searchStr, replaceStr);
                }
            }

            if (pThis.Tag != null)
            {
                Model.RegInfo regInfo = pThis.Tag as Model.RegInfo;
                regInfo.SearchAndReplace(searchStr, replaceStr);
                pThis.Text = string.Format("{0}={1}:{2}", regInfo.ValueName, regInfo.Kind, regInfo.Value);
            }
        }
Ejemplo n.º 3
0
        private void GetRegFileValue(Model.RegInfo regInfo, out string regKind, out string regValue)
        {
            regKind  = "";
            regValue = "";
            switch (regInfo.Kind)
            {
            case nameof(REG_DWORD):
                regKind  = REG_DWORD;
                regValue = regInfo.Value;
                break;

            case nameof(REG_QWORD):
                regKind  = REG_QWORD;
                regValue = regInfo.Value;
                break;

            case nameof(REG_SZ):
                regKind = "";
                if (!string.IsNullOrWhiteSpace(regInfo.Value))
                {
                    regValue = string.Format("\"{0}\"", regInfo.Value);
                }
                break;

            case nameof(REG_EXPAND_SZ):
                regKind  = REG_EXPAND_SZ;
                regValue = regInfo.Value;
                break;

            case nameof(REG_BINARY):
                regKind  = REG_BINARY;
                regValue = regInfo.Value;
                break;

            case nameof(REG_MULTI_SZ):
                regKind  = REG_MULTI_SZ;
                regValue = regInfo.Value;
                break;

            default:
                regKind  = regInfo.Kind;
                regValue = regInfo.Value;
                break;
            }
        }
Ejemplo n.º 4
0
        public static string GetNodeValue(this TreeNode pThis, string nodePath = "", string valueName = "@")
        {
            string retVal    = "";
            var    foundNode = string.IsNullOrEmpty(nodePath) ? pThis : pThis.GetNode(nodePath);

            if (foundNode != null)
            {
                foreach (TreeNode node in foundNode.Nodes)
                {
                    Model.RegInfo regInfo = node.Tag as Model.RegInfo;
                    if (regInfo != null && string.Compare(regInfo.ValueName, valueName, true) == 0)
                    {
                        retVal = regInfo.Value;
                    }
                }
            }
            return(retVal);
        }
Ejemplo n.º 5
0
        private void ParseComClass(TreeNode node, out ComClassRegInfo comClassRegInfo, out string comFile)
        {
            comClassRegInfo       = new ComClassRegInfo();
            comClassRegInfo.clsid = node.Text;
            comFile = "";
            comClassRegInfo.description = node.GetNodeValue();
            var progId = node.GetNodeValue("ProgId");

            if (!string.IsNullOrWhiteSpace(progId))
            {
                comClassRegInfo.AddProgId(progId);
            }
            var inprocNode = node.GetNode("InprocServer32");

            if (inprocNode == null)
            {
                inprocNode = node.GetNode("InprocHandler32");
            }
            if (inprocNode != null)
            {
                foreach (TreeNode inprocItem in inprocNode.Nodes)
                {
                    Model.RegInfo regInfo = inprocItem.Tag as Model.RegInfo;
                    if (regInfo != null && regInfo.ValueName == "@")
                    {
                        string comFilePath = regInfo.Value.Replace(@"\\", @"\");
                        int    startPos    = comFilePath.LastIndexOf("\\");
                        if (startPos != -1)
                        {
                            comFilePath = comFilePath.Substring(startPos + 1);
                        }
                        comFile = comFilePath;
                    }
                    else if (regInfo != null && string.Compare(regInfo.ValueName, "ThreadingModel", true) == 0)
                    {
                        comClassRegInfo.threadingModel = regInfo.Value;
                    }
                }
            }
            else
            {
                comClassRegInfo.tlbid = node.GetNodeValue("TypeLib");
            }
        }