WPF 应用程序开机自启动及窗体关闭按钮作用失效的解决办法
2013-03-14 11:15
676 查看
1、写的一个WPF应用程序,如何开机自启动?
public void AutoOpen()
{
//获取程序执行路径..
string starupPath = AppDomain.CurrentDomain.BaseDirectory + "HSFJQAlarm.exe";
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.SetValue("david", starupPath);
loca.Close();
}
catch (Exception ex)
{
MessageBox.Show("错误消息为:"+ex.Message);
}
}
2、WPF窗体的关闭按钮如何不起作用?
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
MessageBox.Show("监听程序,不可关闭!");
}
public void AutoOpen()
{
//获取程序执行路径..
string starupPath = AppDomain.CurrentDomain.BaseDirectory + "HSFJQAlarm.exe";
//class Micosoft.Win32.RegistryKey. 表示Window注册表中项级节点,此类是注册表装.
RegistryKey loca = Registry.LocalMachine;
RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
try
{
//SetValue:存储值的名称
run.SetValue("david", starupPath);
loca.Close();
}
catch (Exception ex)
{
MessageBox.Show("错误消息为:"+ex.Message);
}
}
2、WPF窗体的关闭按钮如何不起作用?
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
MessageBox.Show("监听程序,不可关闭!");
}
相关文章推荐
- 【WinCE】WinCE中开机启动应用程序,并且不进桌面的解决办法!
- Deepin系统中文件管理器等应用程序右上角的最大最小化以及关闭按钮不见了的解决办法
- 解决 应用程序无法正常启动(0xc0000142)。请单击‘确认’关闭应用程序” 的办法
- codeblock异常关闭,重新开机,启动时提示有另外的实例在运行的解决办法。
- WPF—DocumentGroup中用到了WindowsFormsHost,窗体浮动的时候winform控件不可见的解决办法
- 启动和关闭ADB服务失败的解决办法
- WPF中使窗体关闭按钮与自定义的退出按钮行为一致的做法
- vista ie7 window.confirm() 取消按钮 失效 解决办法
- 电脑开机启动报错解决办法
- weblogic非正常关闭 启动不起来解决办法
- 应用程序无法正常启动(0xc000007b)。请单击“确定”关闭应用程序 解决
- Tomcat 启动和关闭时关于Apache Portable Runtime的错误信息解决办法
- ie中按钮onclick等事件失效。提示提示对象不支持此操作。在谷歌浏览器中又能使用解决办法
- win7下安装centos6.5后,开机无法进入选择双系统启动界面,只能启动centos的解决办法
- 关于wxwidgets图形界面的关闭窗口的按钮无效的解决办法
- VC窗体上的关闭按钮失效
- C# :Response.End() 后页面按钮等功能全部失效的解决办法
- 解决Eclipse打开后闪退 Eclipse在异常关闭后,启动闪退的解决办法
- [原创] monkeytalk 启动、关闭应用程序 解决方法
- 解决点击关闭按钮,应用程序退出时,系统爆出“集合已修改,可能无法执行枚举操作”异常的相关思路