Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- //gunakan directive ini terlebih dahulu
- using Microsoft.Win32;
- namespace StartUpApp
- {
- public partial class Form1 : Form
- {
- RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
- //atau bisa juga pakai di bawah ini untuk run pada semua user yang login
- //
- //ganti CurrentUser dengan LocalMachine
- //RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
- public Form1()
- {
- InitializeComponent();
- //kita akan mengecek apakah sudah jalan di startup atau belum
- if (rk.GetValue("StartUpApp") == null)
- {
- checkBoxStartUp.Checked = false;
- }
- else
- {
- checkBoxStartUp.Checked = true;
- }
- }
- private void buttonClose_Click(object sender, EventArgs e)
- {
- if (checkBoxStartUp.Checked == true)
- {
- rk.SetValue("StartUpApp", Application.ExecutablePath.ToString());
- }
- else
- {
- rk.DeleteValue("StartUpApp", false);
- }
- Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment