Den Code habe ich mal gefunden ist aber leider in C#! Schau mal bei opennetcf.com vorbei. Solltest Du mal einige Interessante Sachen zum PPC finden, dann lass es mich wissen. Das aktivieren des PPC ist laut opennetcf.com nicht möglich!
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
namespace DisplayOff
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.MainMenu mainMenu1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.button1 = new System.Windows.Forms.Button();
//
// button1
//
this.button1.Location = new System.Drawing.Point(24, 16);
this.button1.Size = new System.Drawing.Size(192, 24);
this.button1.Text = "Turn display off for 5 sec";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.Controls.Add(this.button1);
this.Menu = this.mainMenu1;
this.MinimizeBox = false;
this.Text = "Form1";
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
IntPtr hDC = GetDC(IntPtr.Zero);
int Esc = QUERYESCSUPPORT;
//if ( ExtEscape(hDC, QUERYESCSUPPORT, Marshal.SizeOf(Esc.GetType()), ref _
Esc, 0, IntPtr.Zero ) == IntPtr.Zero )
//{
// MessageBox.Show("This device does not support display power on/off");
//}
//else
//{
int[] vpm = new int[3];
vpm[0] = 3 * Marshal.SizeOf(typeof(int));
vpm[1] = 1;
vpm[2] = (int)VIDEO_POWER_STATE.VideoPowerOff;
ExtEscape(hDC, SETPOWERMANAGEMENT, vpm[0], vpm, 0, IntPtr.Zero);
Thread.Sleep(1000);
vpm[2] = (int)VIDEO_POWER_STATE.VideoPowerOn;
ExtEscape(hDC, SETPOWERMANAGEMENT, vpm[0], vpm, 0, IntPtr.Zero);
//}
ReleaseDC(IntPtr.Zero, hDC);
}
[DllImport("coredll")]
extern static IntPtr GetDC(IntPtr hWnd);
[DllImport("coredll")]
extern static void ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("coredll")]
extern static IntPtr ExtEscape(IntPtr hDC, int Esc, int cbInData, int[] _
InData, int cbOutData, IntPtr OutData);
[DllImport("coredll")]
extern static IntPtr ExtEscape(IntPtr hDC, int Esc, int cbInData, ref int _
InData, int cbOutData, IntPtr OutData);
enum VIDEO_POWER_STATE
{
VideoPowerOn = 1,
VideoPowerStandBy,
VideoPowerSuspend,
VideoPowerOff
}
const int SETPOWERMANAGEMENT = 6147;
const int QUERYESCSUPPORT = 8;
}
} |