c#启动系统控制面板程序
c#启动系统控制面板程序
using System.Runtime.InteropServices;
[DllImport("kernel32.dll")]
public static extern bool WinExec(string CmdLine,int uCmdShow);
public const int SW_RESTORE=9;
private void button1_Click(object sender, System.EventArgs e)
{//启动控制面板
WinExec("rundll32.exe shell32.dll,Control_RunDLL",SW_RESTORE);
}
private void button2_Click(object sender, System.EventArgs e)
{//启动显示属性\桌面
WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0",SW_RESTORE);
}
private void button3_Click(object sender, System.EventArgs e)
{//启动显示属性\屏幕保护程序
WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1",SW_RESTORE);
}
private void button4_Click(object sender, System.EventArgs e)
{//设置显示属性\设置
WinExec("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3",SW_RESTORE);
}
===============
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtr hwnd,int wMsg,int wParam,int lParam);
public const int WM_SYSCOMMAND=0x0112;
public const int SC_SCREENSAVE=0xF140;
private void button1_Click(object sender, System.EventArgs e)
{//启动屏幕保护程序
SendMessage(this.Handle,WM_SYSCOMMAND,SC_SCREENSAVE,0);
}

浙公网安备 33010602011771号