C # Call Control Panel options

Source: Internet
Author: User
Control C # is a new development language developed by Microsoft, and it is an emerging development tool based on the Microsoft. NET Framework platform.

Because it was introduced by Microsoft, its compatibility and interoperability with all of Microsoft's products was beyond the programming language developed by other companies. The relationship between the Windows operating system developed by Microsoft and C # is also very close. This enables C # seamless operation of Windows.

Below, let's take a look at the connection between the "C # Action on the options in Windows Control Panel."

In the Windows operating system, the Control Panel file is typically a ". cpl" suffix, and the following table lists the common options and their file names for Windows Control Panel:

-------------------------------------------------------------------------------------------------

Option file name

--------------------------------------------------------------------------------------------------

Internet Options: Inetcpl.cpl

ODBC Data source management: Odbccp32.cpl

Phone and Modem Options: telephon.cpl

Power Options: Powercfg.cpl

Accessibility Options: Access.cpl

Regional and Language Options: intl.cpl

Date and time: timedate.cpl

Sound and Audio Devices: mmsys.cpl

Mouse: main.cpl

Add or Remove Programs: appwiz.cpl

Add Hardware: hdwwiz.cpl

Network connection: Ncpa.cpl

System: Sysdm.cpl

Show: Desk.cpl

User account: Nusrmgr.cpl

Game controller: Joy.cpl

Voice: Sapi.cpl

----------------------------------------------------------------------------------------------------

Font: Fonts

----------------------------------------------------------------------------------------------------

These are the options in the common Control Panel.

Operation:

We can open an operation in C # in the following ways:

A using system.diagnostics;//is called when the namespace is invoked.

In event handling we can use the following methods:

Try

{

Process.Start ("[with full name of the filename above]");

}

catch (Win32Exception Win32ex)

{

MessageBox.Show ("Cause of Error:" +win32ex.) Message, "Error", Messageboxbuttons.ok,messageboxicon.error);

}

Example:

Let's take the Internet option as an example:

Let's revise the above code to read:

Using System.Diagnostics;

ProcessStartInfo info=new ProcessStartInfo ();

Try

{

Info.filename= "Inetcpl.cpl";

Process.Start (Info);

}

catch (Win32Exception Win32ex)

{

MessageBox.Show ("Cause of Error:" +win32ex.) Message, "Error", Messageboxbuttons.ok,messageboxicon.error);

}

The following effects occur after the program is run:



If we do not enter the full file name in the program, an error will occur and the following message appears:



Attached source code:

Using System;

Using System.Drawing;

Using System.Collections;

Using System.ComponentModel;

Using System.Windows.Forms;

Using System.Data;

Using System.Diagnostics;



Namespace Csharpcallcpl

{

<summary>

Summary description of the Form1.

</summary>

public class Form1:System.Windows.Forms.Form

{

Private System.Windows.Forms.Button button1;

Private System.Windows.Forms.Label Label1;

<summary>

The required designer variable.

</summary>

Private System.ComponentModel.Container components = null;



Public Form1 ()

{

//

Required for Windows Forms Designer support

//

InitializeComponent ();



//

TODO: Add any constructor code after the InitializeComponent call

//

}



<summary>

Clean up all resources that are in use.

</summary>

protected override void Dispose (bool disposing)

{

if (disposing)

{

if (Components!= null)

{

Components. Dispose ();

}

}

Base. Dispose (disposing);

}



#region Windows Form Designer generated code

<summary>

Designer supports required methods-do not use the Code editor to modify

The contents of this method.

</summary>

private void InitializeComponent ()

{

This.button1 = new System.Windows.Forms.Button ();

This.label1 = new System.Windows.Forms.Label ();

This. SuspendLayout ();

//

Button1

//

This.button1.Location = new System.Drawing.Point (192, 72);

This.button1.Name = "Button1";

This.button1.TabIndex = 0;

This.button1.Text = "call";

This.button1.Click + = new System.EventHandler (This.button1_click);

//

Label1

//

This.label1.AutoSize = true;

This.label1.Font = new System.Drawing.Font ("XXFarEastFont-Arial", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte) (134));

This.label1.Location = new System.Drawing.Point (40, 16);

This.label1.Name = "Label1";

This.label1.Size = new System.Drawing.Size (203, 24);

This.label1.TabIndex = 1;

This.label1.Text = "C # Call Control Panel paradigm";

//

Form1

//

This. AutoScaleBaseSize = new System.Drawing.Size (6, 14);

This. ClientSize = new System.Drawing.Size (296, 125);

This. Controls.AddRange (new system.windows.forms.control[] {

This.label1,

This.button1});

This. Name = "Form1";

This. Text = "Form1";

This. ResumeLayout (FALSE);



}

#endregion



<summary>

The main entry point for the application.

</summary>

[STAThread]

static void Main ()

{

Application.Run (New Form1 ());

}



private void Button1_Click (object sender, System.EventArgs e)

{

ProcessStartInfo info=new ProcessStartInfo ();

Try

{

Info.filename= "Inetcpl.cpl";

Process.Start (Info);

}

catch (Win32Exception Win32ex)

{

MessageBox.Show ("Cause of Error:" +win32ex.) Message, "Error", Messageboxbuttons.ok,messageboxicon.error);

}

}

}

}


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.