Touch screen browser-started with Windows

Source: Internet
Author: User

I have various ways to start running

This section describes a common

Use the configuration file to set whether to boot

1,

Set a function to check whether a auto-START key exists.
Private bool isvalueexist (string keyValue)
{
Registrykey HKLM = registry. localmachine;
Registrykey run = HKLM. createsubkey (@ "software/Microsoft/Windows/CurrentVersion/Run ");

String valuestr1 = NULL;

Try
{
Valuestr1 = (string) Run. getvalue (keyValue );
HKLM. Close ();
}
Catch (exception er1)
{
MessageBox. Show (er1.message. tostring (), "prompt", messageboxbuttons. OK, messageboxicon. Error );
}

If (valuestr1 = NULL)
Return false;
Else
Return true;

}

 

2,

Setautovalue ()
Private void setautovalue (string keyValue)
{

// Check whether the key value already exists and will not be registered again
Bool RT = This. isvalueexist (keyValue );
If (RT)
{
// MessageBox. Show (keyValue + "already exists, no longer created ");
Return;
}

Registrykey HKLM = registry. localmachine;
Registrykey run = HKLM. createsubkey (@ "software/Microsoft/Windows/CurrentVersion/Run ");

Try
{
Run. setvalue (keyValue, application. executablepath); // obtain the path and file name
// MessageBox. Show ("it has been set to auto-start !! "," Prompt ", messageboxbuttons. OK, messageboxicon. information );
HKLM. Close ();
}

Catch (exception my)
{
MessageBox. Show (My. Message. tostring (), "prompt", messageboxbuttons. OK, messageboxicon. Error );
}
}

3,

Delautovalue ()
Private void delautovalue (string keyValue)
{

// Check whether the key value already exists. If it does not exist, no operation is performed.
Bool RT = This. isvalueexist (keyValue );
If (! RT)
{
// MessageBox. Show (keyValue + "does not exist, no operation required ");
Return;
}

Registrykey HKLM = registry. localmachine;
Registrykey run = HKLM. createsubkey (@ "software/Microsoft/Windows/CurrentVersion/Run ");

Try
{
// Run. setvalue (keyValue, application. executablepath); // obtain the path and file name
Run. deletevalue (keyValue );
// MessageBox. Show ("auto start has been successfully canceled !! "," Prompt ", messageboxbuttons. OK, messageboxicon. information );
HKLM. Close ();
}

Catch (exception my)
{
MessageBox. Show (My. Message. tostring (), "prompt", messageboxbuttons. OK, messageboxicon. Error );
}

}

4,

Main function autostartswitch ()
Private void autostartswitch (string keynamevalue, bool istart)
{
If (istart)
This. setautovalue (keynamevalue );
Else
This. delautovalue (keynamevalue );
Return;
}

String auto = "Auto ";

String autovalue = "";

5,

Whether to enable automaticoperation ()
Private void automaticoperation ()
{
Autovalue = getconfigvalue ("setautovalue ");
This. isvalueexist ("self-start running ");
Try
{
If (Auto = autovalue)
{
Autostartswitch ("self-starting", true );

}
If (Auto! = Autovalue)
{
Autostartswitch ("self-starting", false );

}
}
Catch (exception)
{
Return;
}
}

6,

The following is the configuration file touchscreenbrowser. xml.

<? XML version = "1.0" encoding = "UTF-8"?>
<Touchbrowser>
<Setautovalue> auto </setautovalue>
</Touchbrowser>

7,

Getconfigvalue ()

// Obtain the configuration file value
Protected string getconfigvalue (string configname)
{
Xmldocument xmldoc = new xmldocument ();

Xmldoc. Load (application. startuppath + "/touchscreenbrowser. xml ");

Xmlnodelist nodelist = xmldoc. selectsinglenode ("touchbrowser"). childnodes; // retrieve all child nodes of the touchbrowser Node

Foreach (xmlnode Xn in nodelist) // traverses all subnodes
{
If (Xn. Name = configname)
{
Return XN. innertext;
}
}

Return "";

}

Source code download: http://download.csdn.net/source/645945

 

Related Article

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.