리눅스맨

윈도우 시작 프로그램, 윈도우 시작시 프로그램 자동실행, 윈도우 시작시 프로그램 자동실행 소스코드, 윈도우 자동 실행 프로그램

윈도우 시작시 프로그램 자동실행 c# 제작 소스코드

Background Image
1,000만원 수익
Overlay Image

윈도우 시작시 프로그램 자동실행 소스코드

보통 체크박스를 이용하여 윈도우 시작시 프로그램이 자동으로 실행하게 할껀지 아닐지 여부를 선택합니다.

윈도우 시작 프로그램, 윈도우 시작시 프로그램 자동실행, 윈도우 시작시 프로그램 자동실행 소스코드, 윈도우 자동 실행 프로그램
윈도우 시작시 프로그램 자동실행 c# 제작 소스코드 5

이렇게 체크박스를 만들어서 체크를 할 경우 윈도우시작할때 바로 프로그램이 실행되도록 할 수 있습니다.

윈도우 시작시 프로그램 자동실행 소스코드

// init()

            try
            {
                if (ReadValue("info", "checkBox_윈도우자동시작") != null)
                {
                    string text = ReadValue("info", "checkBox_윈도우자동시작");

                    if (text == "true")
                    {
                        checkBox_윈도우자동시작.Checked = true;

                    }
                    else
                    {
                        checkBox_윈도우자동시작.Checked = false;
                    }

                }

            }
            catch { }


// checkbox click

        RegistryKey runRegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

        private void checkBox_윈도우자동시작_CheckedChanged(object sender, EventArgs e)
        {
            string 프로그램명 = string.Format("{0}", System.IO.Path.GetFileName(Application.ExecutablePath));
            if (checkBox_윈도우자동시작.Checked)
            {
                runRegKey.SetValue(프로그램명,string.Format("{0}{1}", System.AppDomain.CurrentDomain.BaseDirectory, System.IO.Path.GetFileName(Application.ExecutablePath)
));
                WriteValue("info", "checkBox_윈도우자동시작", "true");
            }
            else
            {
                runRegKey.DeleteValue(프로그램명, false);
                WriteValue("info", "checkBox_윈도우자동시작", "false");
            }
        }

사실 위의 소스코드에서 가장 중요한 부분은 바로 RegistryKey 항목입니다.

RegistryKey runRegKey = Registry.CurrentUser.OpenSubKey(“SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run”, true);

윈도우 시작 프로그램, 윈도우 시작시 프로그램 자동실행, 윈도우 시작시 프로그램 자동실행 소스코드, 윈도우 자동 실행 프로그램
윈도우 시작시 프로그램 자동실행 c# 제작 소스코드 6

레지스트리키에다가 현재 프로그램을 등록하는것이죠.

윈도우 시작 프로그램, 윈도우 시작시 프로그램 자동실행, 윈도우 시작시 프로그램 자동실행 소스코드, 윈도우 자동 실행 프로그램
윈도우 시작시 프로그램 자동실행 c# 제작 소스코드 7

윈도우 7, 8, 10, 11 시작프로그램 항목에 넣어서 할수도 있지만 조금 다른 부분은 바로가기 형식의 파일 링크를 걸어두는게 아닌 레지스트리키에 프로그램 경로를 String(문자열) 형태로 입력하는 방식입니다.

이제 언제든지 컴퓨터를 켤때마다 자동으로 프로그램이 실행됩니다.

Background Image
1,000만원 수익
Overlay Image

게시됨

카테고리

, ,

작성자

태그: