Kod źródłowy:
[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using System.Net;
using System.Media;
using System.Threading;
namespace RunAtStartup
{
public partial class frmStartup : Form
{
private SoundPlayer Player = new SoundPlayer();
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
public frmStartup()
{
InitializeComponent();
if (rkApp.GetValue("MyApp") == null)
{
chkRun.Checked = false;
}
else
{
chkRun.Checked = true;
}
}
private void btnOk_Click(object sender, EventArgs e)
{
if (chkRun.Checked)
{
rkApp.SetValue("MyApp", Application.ExecutablePath.ToString());
}
else
{
rkApp.DeleteValue("MyApp", false);
}
}
private void frmStartup_Load(object sender, EventArgs e)
{
try
{
this.Player.SoundLocation = @"...\MyApp\Start.wav";
this.Player.PlaySync();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Błąd aplikacji.");
}
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pictureBox1.Image = System.Drawing.Image.FromFile(@"...\MyApp\narzedzia2.png");
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
pictureBox1.Image = System.Drawing.Image.FromFile(@"...\MyApp\narzedzia.gif");
}
}
}
[/code]