Core code for VB.NET:
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
Namespace PDANamespace PDA
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Class VideoClass Video
Private Const SETPOWERMANAGEMENT As Int32 = 6147
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Declare Function ExtEscapeSet()Function ExtEscapeSet Lib "coredll" Alias "ExtEscape" (ByVal hdc As IntPtr, _
ByVal nEscape As Int32, _
ByVal cbInput As Int32, _
ByVal plszInData As Byte(), _
ByVal cbOutput As Int32, _
ByVal lpszOutData As IntPtr) As Int32
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Declare Function GetDC()Function GetDC Lib "coredll" (ByVal hwnd As IntPtr) As IntPtr
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Enum VideoPowerStateEnum VideoPowerState As Integer
VideoPowerOn = 1
VideoPowerStandBy
VideoPowerSuspend
VideoPowerOff
End Enum
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Shared Sub PowerOff()Sub PowerOff()
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
Dim vpm() As Byte = {12, 0, 0, 0, 1, 0, 0, 0, VideoPowerState.VideoPowerOff, 0, 0, 0, 0}
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero)
End Sub
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Public Shared Sub PowerOn()Sub PowerOn()
Dim hdc As IntPtr = GetDC(IntPtr.Zero)
Dim vpm() As Byte = {12, 0, 0, 0, 1, 0, 0, 0, VideoPowerState.VideoPowerOn, 0, 0, 0, 0}
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, 12, vpm, 0, IntPtr.Zero)
End Sub
End Class
End Namespace Core code for C#
using System;
using System.Runtime.InteropServices;
![](/Images/OutliningIndicators/None.gif)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
Namespace OpenNETCFnamespace OpenNETCF
{
/// <summary>
/// Summary description for Video.
/// </summary>
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public Class Videoclass Video
{
// GDI Escapes for ExtEscape()
private const uint QUERYESCSUPPORT = 8;
![](/Images/OutliningIndicators/InBlock.gif)
// The following are unique to CE
private const uint GETVFRAMEPHYSICAL = 6144;
private const uint GETVFRAMELEN = 6145;
private const uint DBGDRIVERSTAT = 6146;
private const uint SETPOWERMANAGEMENT = 6147;
private const uint GETPOWERMANAGEMENT = 6148;
![](/Images/OutliningIndicators/InBlock.gif)
public static void PowerOff()
{
IntPtr hdc = GetDC(IntPtr.Zero);
uint func = SETPOWERMANAGEMENT;
![](/Images/OutliningIndicators/InBlock.gif)
uint size = 12;
byte[] vpm = new byte[size];
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
//Structure sizestructure size
BitConverter.GetBytes(size).CopyTo(vpm, 0);
//dpms version
BitConverter.GetBytes(0x0001).CopyTo(vpm, 4);
//power state
BitConverter.GetBytes((uint)VideoPowerState.VideoPowerOff).CopyTo(vpm, 8);
![](/Images/OutliningIndicators/InBlock.gif)
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, size, vpm, 0, IntPtr.Zero);
}
![](/Images/OutliningIndicators/InBlock.gif)
public static void PowerOn()
{
IntPtr hdc = GetDC(IntPtr.Zero);
![](/Images/OutliningIndicators/InBlock.gif)
uint size = 12;
byte[] vpm = new byte[size];
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
//Structure sizestructure size
BitConverter.GetBytes(size).CopyTo(vpm, 0);
//dpms version
BitConverter.GetBytes(0x0001).CopyTo(vpm, 4);
//power state
BitConverter.GetBytes((uint)VideoPowerState.VideoPowerOn).CopyTo(vpm, 8);
![](/Images/OutliningIndicators/InBlock.gif)
ExtEscapeSet(hdc, SETPOWERMANAGEMENT, size, vpm, 0, IntPtr.Zero);
}
![](/Images/OutliningIndicators/InBlock.gif)
[DllImport("coredll", EntryPoint="ExtEscape")]
private static extern int ExtEscapeSet(
IntPtr hdc,
uint nEscape,
uint cbInput,
byte[] lpszInData,
int cbOutput,
IntPtr lpszOutData
);
![](/Images/OutliningIndicators/InBlock.gif)
[DllImport("coredll")]
private static extern IntPtr GetDC(IntPtr hwnd);
![](/Images/OutliningIndicators/InBlock.gif)
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public Enum VideoPowerStateenum VideoPowerState : uint
{
VideoPowerOn = 1,
VideoPowerStandBy,
VideoPowerSuspend,
VideoPowerOff
}
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
posted @
2005-08-03 23:09
Dream world 梦想天空
阅读(
692)
评论()
编辑
收藏
举报