界面如下图: 代码如下: 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 ScreenControl { public partial class Form1 : Form { /// <summary> /// 电源状态 /// 具体解释请参阅MSDN中:CEDEVICE_POWER_STATE /// </summary> public enum PowerState { PwrDeviceUnspecified = -1, FullOn = 0, LowOn = 1, Standby = 2, Sleep = 3, Off = 4, PwrDeviceMaximum = 5 } IntPtr hPower; public Form1() { InitializeComponent(); } //开灯 private void btn_open_Click(object sender, EventArgs e) { DevicePowerNotify("BKL1:", PowerState.FullOn, 1); } //关闭 private void btn_off_Click(object sender, EventArgs e) { DevicePowerNotify("BKL1:", PowerState.Off, 1); } //保持长亮 private void btn_keep_Click(object sender, EventArgs e) { hPower = SetPowerRequirement("BKL1:", PowerState.FullOn, 1, null, 0); } //取消长亮 private void btn_cancel_Click(object sender, EventArgs e) { if (hPower != null) ReleasePowerRequirement(hPower); } #region 引用的API函数,具体说明请参阅MSDN [DllImport("CoreDll", SetLastError = true)] static extern IntPtr SetPowerRequirement(string DeviceName, PowerState State, uint dwDeviceFlags, string Name, ulong Reserved); [DllImport("CoreDll", SetLastError = true)] static extern int ReleasePowerRequirement(IntPtr hPowerReq); [DllImport("coredll.dll")] private static extern int DevicePowerNotify(string device, PowerState deviceState, int deviceFlags); #endregion } }