C # call control panel option

zhaozj2021-02-16  59

C # call control panel option

C # is a new development language that is newly launched by Microsoft, which is an emerging development tool based on Microsoft .NET Framework platform.

Because it is launched by Microsoft, it is not possible to compatibility with all products of Microsoft's products and mutual operability is the programming language developed by other companies. The relationship between the Windows operating system and C # developed by Microsoft is also very close. Thereby achieving a seamless operation of C # on Windows.

Below, we will talk about the links between the Windows Control Panel in "C #" in the Windows Control Panel.

In the Windows operating system, the files of the control panel are typically in the ".cpl" suffix, the following table lists the common options common to the Windows Control Panel and their file names:

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

Option file name

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

Internet Options: inetcpl.cpl

ODBC Data Source Management: ODBCCP32.CPL

Telephone and modem options: Telephon.cpl

Power options: powercfg.cpl

Auxiliary function options: access.cpl

Region and Language Options: INTL.CPL

Date and time: TIMEDATE.CPL

Sound and audio equipment: mmsys.cpl

Mouse: main.cpl

Add or delete programs: AppWiz.cpl

Add hardware: HDWWIZ.CPL

Network connection: NCPA.CPL

System: sysdm.cpl

Display: desk.cpl

User Account: NusRMgr.cpl

Game controller: joy.cpl

Voice: SAPI.CPL

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

Font: fonts

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

These are the options in the commonly used control panels.

operating:

We can open the operation in the following ways:

Using system.diagnostics; // calls when the namespace is called.

// We can use it in event processing: TRY

{

Process.start ("[[Take the above file name full name]")

}

Catch (Win32Exception Win32ex)

{

Messagebox.show ("For the reason:" Win32Ex.Message, "Error", MessageBoxButtons.ok, MessageBoxicon.Error;

}

Example:

We use the Internet option as an example:

We modify the above code to:

Using system.diagnostics;

ProcessStartInfo Info = New ProcessStartInfo ();

Try

{

Info.filename = "inetcpl.cpl";

Process.start (Info);

}

Catch (Win32Exception Win32ex)

{

Messagebox.show ("For the reason:" Win32Ex.Message, "Error", MessageBoxButtons.ok, MessageBoxicon.Error;

}

The following effects appear after the program is run:

If we do not enter a complete file name in the program, it will generate an error and appear as follows:

Attached code:

Using system;

Using system.drawing;

Using system.collections;

Using system.componentmodel;

Using system.windows.forms;

Using system.data;

Using system.diagnostics;

Namespace CsharpCallCPL

{

///

/// Form1 summary description.

///

Public Class Form1: System.Windows.Forms.form

{

Private system.windows.Forms.Button button1;

Private system.windows.Forms.Label label1;

///

/// The required designer variable.

///

Private system.componentmodel.Container Components = NULL;

Public Form1 ()

{

//

// Windows Form Designer Support

//

InitializationComponent ();

//

// Todo: Add any constructor code after INITIALIZECOMPONENT call

//

}

///

/// Clean all the resources being used.

///

Protected Override Void Dispose (Bool Disposing)

{

IF (Disposing)

{

IF (Components! = NULL)

{

Components.dispose ();

}

}

Base.dispose (Disposing);

}

#Region Windows Form Designer Generated Code

///

/// Designer supports the required method - do not use the code editor to modify

/// This method is content.

///

Private vidinitiRizeComponent ()

{

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 ("Song", 15.75F, System.drawing.FontStyle.Bold, System.drawing.graphicsUnit.Point ((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 Example";

//

// 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);

}

#ndregion

///

/// The main entry point for the application.

///

[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 ("For the reason:" Win32Ex.Message, "Error", MessageBoxButtons.ok, MessageBoxicon.Error;

}

}

}

}

Finally, because the author is limited, you can't give you better articles, you will see you forgive. And ask all the official criticism to correct.

转载请注明原文地址:https://www.9cbs.com/read-24067.html

New Post(0)