示例#1
0
        public static int GetIeVersionMajor()
        {
            // HKLM\SOFTWARE\Microsoft\Internet Explorer\Version
            string Section  = @"SOFTWARE\Microsoft\Internet Explorer";
            object oVersion = CRegistry.GetSetting(HRootKeys.HKEY_LOCAL_MACHINE, Section, "Version", null);

            if (oVersion == null)
            {
                return(0);
            }

            string[] aVersion = ((string)oVersion).Split('.');
            int      Version  = Convert.ToInt32(aVersion[0]);

            //10 버전이면 Version은 9로 시작하고 svcVersion이 10으로 시작함.
            if (Version >= 9)
            {
                oVersion = CRegistry.GetSetting(HRootKeys.HKEY_LOCAL_MACHINE, Section, "svcVersion", null);
                if (oVersion == null)
                {
                    return(Version);
                }

                aVersion = ((string)oVersion).Split('.');
                Version  = Convert.ToInt32(aVersion[0]);
            }

            return(Version);
        }
示例#2
0
        public static string GetWinwordFullPath()
        {
            string Section   = @"Applications\Winword.exe\shell\edit\command";
            object oFullPath = CRegistry.GetSetting(HRootKeys.HKEY_CLASSES_ROOT, Section, "", "");

            if (oFullPath == null)
            {
                return("");
            }

            string FullPath = GetExeFullPath((string)oFullPath);

            return(FullPath);
        }
示例#3
0
        public static void RestoreListControlSelectedIndex(string AppProductName, ContainerControl FrmOrUc, ListControl lst, CXmlConfig xc)
        {
            string FrmOrUcName = FrmOrUc.Name;
            string Section     = AppProductName + "\\" + FrmOrUcName;
            string ControlName = lst.Name;

            int SelectedIndex =
                (xc != null) ?
                CFindRep.IfNotNumberThen0(xc.GetSetting(FrmOrUcName + "." + ControlName, lst.SelectedIndex)) :
                CFindRep.IfNotNumberThen0(CRegistry.GetSetting(Section, ControlName, lst.SelectedIndex));

            if (lst.SelectedIndex != SelectedIndex)
            {
                //Items.Count 읽을 수 없어 try 사용.
                try { lst.SelectedIndex = SelectedIndex; }
                catch (Exception) { }
            }
        }
示例#4
0
        private static string GetHwpFullPath(HwpVersion Version)
        {
            List <string> aSectionCur = new List <string>();

            if (Version == HwpVersion._None_0)
            {
                //버전은 알 수 없어도 한글 파일 경로를 리턴하기 위함.
                aSectionCur.Add(@"Hwp.Document\shell\Open\command");
            }
            else
            {
                aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\shell\Open\command");
                aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\shell\DefaultIcon");
                aSectionCur.Add(@"Hwp.Document." + ((int)Version).ToString() + @"\DefaultIcon");
            }

            for (int j = 0; j < aSectionCur.Count; j++)
            {
                object oFullPathCur = CRegistry.GetSetting(HRootKeys.HKEY_CLASSES_ROOT, aSectionCur[j], "", null);
                if (oFullPathCur == null)
                {
                    continue;
                }

                string FullPathCur = GetExeFullPath((string)oFullPathCur);

                //HwpView.exe인 경우도 있음.
                if (FullPathCur.IndexOf("Hwp.exe", StringComparison.CurrentCultureIgnoreCase) == -1)
                {
                    continue;
                }

                if (File.Exists(FullPathCur))
                {
                    return(FullPathCur);
                }
            }

            return(string.Empty);
        }
示例#5
0
        //http://stackoverflow.com/questions/17922308/use-latest-version-of-ie-in-webbrowser-control
        public static void SetWebBrowserControlVersion(string ProcessNameWithExtension, int IeVersionMajor)
        {
            int nBrowserEmulationNew = (int)BrowserEmulation._07Doctype;

            if (IeVersionMajor >= 11)
            {
                nBrowserEmulationNew = (int)BrowserEmulation._11IgnoreDoctype;
            }
            else if (IeVersionMajor >= 10)
            {
                nBrowserEmulationNew = (int)BrowserEmulation._10IgnoreDoctype;
            }
            else if (IeVersionMajor >= 9)
            {
                nBrowserEmulationNew = (int)BrowserEmulation._09IgnoreDoctype;
            }
            else if (IeVersionMajor >= 8)
            {
                nBrowserEmulationNew = (int)BrowserEmulation._08IgnoreDoctype;
            }
            else if (IeVersionMajor >= 7)
            {
                nBrowserEmulationNew = (int)BrowserEmulation._07Doctype;
            }

            //HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
            //(When 64bit OS, the value will save to HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\... node.)
            string Section = @"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
            object oValue  = CRegistry.GetSetting(HRootKeys.HKEY_LOCAL_MACHINE, Section, ProcessNameWithExtension, (int)BrowserEmulation._07Doctype);
            int    nBrowserEmulationOld = Convert.ToInt32(oValue);

            if (nBrowserEmulationNew != nBrowserEmulationOld)
            {
                CRegistry.SaveSetting(HRootKeys.HKEY_LOCAL_MACHINE, Section, ProcessNameWithExtension, nBrowserEmulationNew, RegistryValueKind.DWord);
            }
        }
示例#6
0
        /// <summary>
        /// 미리 저장된 Form의 위치와 크기 정보를 불러와서 현재 폼의 위치와 크기를 변경함.
        /// </summary>
        /// <param name="AppProductName">Application.ProductName</param>
        /// <param name="FrmOrUc">Form 개체</param>
        /// <param name="Kind">저장될 값의 종류</param>
        /// <example>
        /// 다음은 폼이 닫힐 때 폼의 위치, 크기 정보를 저장하고,
        /// 폼이 열릴 때 저장되었던 폼의 위치, 크기 정보를 불러와서 열린 폼에 적용합니다.
        /// <code>
        /// private void Form1_Load(object sender, System.EventArgs e)
        /// {
        ///	 CWinForm.RestoreFormStatus(Application.ProductName, this, FormSaveRestoreKind.SizePosition);
        /// }
        /// private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        /// {
        ///	 CWinForm.SaveFormStatus(Application.ProductName, this, FormSaveRestoreKind.SizePosition);
        /// }
        /// </code>
        /// </example>
        public static void RestoreFormStatus(string AppProductName, ContainerControl FrmOrUc, FormSaveRestoreKind Kind, CXmlConfig xc)
        {
            string FrmOrUcName = FrmOrUc.Name;
            string Section     = AppProductName + "\\" + FrmOrUcName;

            if ((Kind & FormSaveRestoreKind.SizePosition) == FormSaveRestoreKind.SizePosition)
            {
                Form frm = (Form)FrmOrUc;

                int LeftWill, TopWill;

                int    WindowStateDefault = (int)FormWindowState.Normal;
                object WindowState        =
                    (xc != null) ?
                    xc.GetSetting(FrmOrUcName + ".WindowState", WindowStateDefault) :
                    CRegistry.GetSetting(Section, "WindowState", WindowStateDefault);

                FormWindowState ws = FormWindowState.Normal;
                try { ws = (FormWindowState)Convert.ToInt32(WindowState); }
                catch (Exception) { }

                if (frm.WindowState != ws)
                {
                    frm.WindowState = ws;
                }

                if (ws == FormWindowState.Normal)
                {
                    int    LeftDefault = frm.Left;
                    object Left        =
                        (xc != null) ?
                        xc.GetSetting(FrmOrUcName + ".Left", LeftDefault) :
                        CRegistry.GetSetting(Section, "Left", LeftDefault);

                    LeftWill = Convert.ToInt32(Left);
                    if (LeftWill < 0)
                    {
                        LeftWill = 0;
                    }

                    int    TopDefault = frm.Top;
                    object Top        =
                        (xc != null) ?
                        xc.GetSetting(FrmOrUcName + ".Top", TopDefault) :
                        CRegistry.GetSetting(Section, "Top", TopDefault);

                    TopWill = Convert.ToInt32(Top);
                    if (TopWill < 0)
                    {
                        TopWill = 0;
                    }

                    if (frm.Left != LeftWill)
                    {
                        frm.Left = LeftWill;
                    }
                    if (frm.Top != TopWill)
                    {
                        frm.Top = TopWill;
                    }

                    switch (frm.FormBorderStyle)
                    {
                    case FormBorderStyle.Fixed3D:
                    case FormBorderStyle.FixedDialog:
                    case FormBorderStyle.FixedSingle:
                    case FormBorderStyle.FixedToolWindow:
                        break;

                    default:
                        int    WidthDefault = frm.Width;
                        object Width        =
                            (xc != null) ?
                            xc.GetSetting(FrmOrUcName + ".Width", WidthDefault) :
                            CRegistry.GetSetting(Section, "Width", WidthDefault);

                        int WidthWill = Convert.ToInt32(Width);
                        if (frm.Width != WidthWill)
                        {
                            frm.Width = WidthWill;
                        }

                        int    HeightDefault = frm.Height;
                        object Height        =
                            (xc != null) ?
                            xc.GetSetting(FrmOrUcName + ".Height", HeightDefault) :
                            CRegistry.GetSetting(Section, "Height", HeightDefault);

                        int HeightWill = Convert.ToInt32(Height);
                        if (frm.Height != HeightWill)
                        {
                            frm.Height = HeightWill;
                        }

                        break;
                    }
                }
            }

            if (((Kind & FormSaveRestoreKind.TextBox) == FormSaveRestoreKind.TextBox) ||
                ((Kind & FormSaveRestoreKind.NumericUpDown) == FormSaveRestoreKind.NumericUpDown) ||
                ((Kind & FormSaveRestoreKind.ListControl) == FormSaveRestoreKind.ListControl) ||
                ((Kind & FormSaveRestoreKind.CheckBox) == FormSaveRestoreKind.CheckBox))
            {
                List <Control> aCtl = new List <Control>();
                aCtl = GetControls(FrmOrUc, ref aCtl);

                foreach (Control ctl in aCtl)
                {
                    Type TypeCur = ctl.GetType();

                    string ControlName = ctl.Name;

                    if (((Kind & FormSaveRestoreKind.TextBox) == FormSaveRestoreKind.TextBox) && (TypeCur.BaseType == typeof(TextBoxBase)))
                    {
                        TextBoxBase txt = (TextBoxBase)ctl;

                        string Value =
                            (xc != null) ?
                            xc.GetSetting(FrmOrUcName + "." + ControlName, txt.Text) :
                            CRegistry.GetSetting(Section, ControlName, txt.Text).ToString();

                        if (txt.Text != Value)
                        {
                            txt.Text = Value;
                        }
                    }
                    else if (((Kind & FormSaveRestoreKind.NumericUpDown) == FormSaveRestoreKind.NumericUpDown) && (TypeCur == typeof(NumericUpDown)))
                    {
                        NumericUpDown nud = (NumericUpDown)ctl;

                        string Value =
                            (xc != null) ?
                            xc.GetSetting(FrmOrUcName + "." + ControlName, nud.Value) :
                            CRegistry.GetSetting(Section, ControlName, nud.Value).ToString();

                        if (nud.Value.ToString() != Value)
                        {
                            nud.Value = (decimal)CFindRep.IfNotNumberThen0Decimal(Value);
                        }
                    }
                    else if (((Kind & FormSaveRestoreKind.ListControl) == FormSaveRestoreKind.ListControl) && (TypeCur.BaseType == typeof(ListControl)))
                    {
                        ListControl lst = (ListControl)ctl;
                        RestoreListControlSelectedIndex(Application.ProductName, FrmOrUc, lst, xc);
                    }
                    else if (((Kind & FormSaveRestoreKind.CheckBox) == FormSaveRestoreKind.CheckBox) && (TypeCur == typeof(CheckBox)))
                    {
                        CheckBox chk = (CheckBox)ctl;

                        bool Checked =
                            (xc != null) ?
                            (xc.GetSetting(FrmOrUcName + "." + ControlName, CFindRep.IfTrueThen1FalseThen0(chk.Checked)) == "1") :
                            (CRegistry.GetSetting(Section, ControlName, CFindRep.IfTrueThen1FalseThen0(chk.Checked)).ToString() == "1");

                        if (chk.Checked != Checked)
                        {
                            chk.Checked = Checked;
                        }
                    }
                    else if (((Kind & FormSaveRestoreKind.RadioButton) == FormSaveRestoreKind.RadioButton) && (TypeCur == typeof(RadioButton)))
                    {
                        RadioButton rad = (RadioButton)ctl;

                        bool Checked =
                            (xc != null) ?
                            (xc.GetSetting(FrmOrUcName + "." + ControlName, CFindRep.IfTrueThen1FalseThen0(rad.Checked)) == "1") :
                            (CRegistry.GetSetting(Section, ControlName, CFindRep.IfTrueThen1FalseThen0(rad.Checked)).ToString() == "1");

                        if (rad.Checked != Checked)
                        {
                            rad.Checked = Checked;
                        }
                    }
                }
            }
        }