我試圖將button1_Click
原因calc.exe
添加到啓動文件夾中。我也想讓計算器在屏幕上隨機彈出。如何將文件添加到啓動文件夾?
我正在使用Visual Studio 2015. 如果還使用java我可以使用什麼代碼將文件添加到按鈕單擊的啓動文件夾。我試圖創建與啓動文件夾的鏈接文件,但我一直在獲取錯誤。文件未找到,即使該文件是在項目文件夾
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using Microsoft.Win32;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Hey : Form
{
public Hey()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("calc.exe");
RegistryKey Key = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run", true);
Key.SetValue("calc.exe", System.Reflection.Assembly.GetEntryAssembly().Location);
}
}
}