using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsApplication1 { public partial class Form1 : System.Windows.Forms.Form { public Form1() { InitializeComponent(); } [DllImport("kernel32.dll")] public static extern bool WinExec(string CmdLine, int uCmdShow); public const int SW_RESTORE = 9; private void button1_Click(object sender, EventArgs e) { WinExec("rundll32.exe shell32.dll,Control_RunDLL", SW_RESTORE); } private void button2_Click(object sender, EventArgs e) { WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0", SW_RESTORE); } private void button3_Click(object sender, EventArgs e) { WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1", SW_RESTORE); } private void button4_Click(object sender, EventArgs e) { WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3", SW_RESTORE); } } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
使用了WIN32API函数
public sealed class DllImportAttribute : System.Attribute System.Runtime.InteropServices 的成员 摘要: 指示该属性化方法由非托管动态链接库 (DLL) 作为静态入口点公开。