Solution for auto-start of the WPF application at startup and failure of the button for closing the form

Source: Internet
Author: User

1. How do I start a WPF Application on startup?

Public void autoopen () {// obtain the program execution path .. string staruppath = appdomain. currentdomain. basedirectory + "hsfjqalarm.exe"; // class Micosoft. win32.registrykey. indicates the entry-level node in the Window registry. This class is installed in the registry. registrykey loca = registry. localmachine; registrykey run = loca. createsubkey (@ "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run"); try {// setvalue: name of the stored value run. setvalue ("David", staruppath); loca. close ();} catch (exception ex) {MessageBox. show ("error message:" + ex. message );}}

 

 

2. How does the close button of the WPF form not work?

Protected override void onclosing (system. componentmodel. canceleventargs e) {e. Cancel = true; MessageBox. Show ("listener, cannot be closed! ");}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.