中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > .NET > 临时文章
HOWTO:Turn Off PDA Display while your application is running.(VB.Net/c#+.Net CF+PPC2003)
作者:未知 时间:2005-07-27 21:41 出处:CSDN 责编:chinaitpower
              摘要:HOWTO:Turn Off PDA Display while your application is running.(VB.Net/c#+.Net CF+PPC2003)

Core code for VB.NET:

Namespace PDA

    Public Class Video

        Private Const SETPOWERMANAGEMENT As Int32 = 6147

 

        Declare 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

 

        Declare Function GetDC Lib "coredll" (ByVal hwnd As IntPtr) As IntPtr

 

        Public Enum VideoPowerState As Integer

            VideoPowerOn = 1

            VideoPowerStandBy

            VideoPowerSuspend

            VideoPowerOff

        End Enum

 

        Public Shared 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

 

        Public Shared 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;

 

namespace OpenNETCF

{

/// <summary>

/// Summary description for Video.

/// </summary>

public class Video

{

        // GDI Escapes for ExtEscape()

        private const uint QUERYESCSUPPORT   = 8;

 

        // 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;

 

        public static void PowerOff()

        {

               IntPtr hdc = GetDC(IntPtr.Zero);

               uint func = SETPOWERMANAGEMENT;

 

               uint size = 12;

               byte[] vpm = new byte[size];

                              

               //structure 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);

 

               ExtEscapeSet(hdc, SETPOWERMANAGEMENT, size, vpm, 0, IntPtr.Zero);

        }

 

        public static void PowerOn()

        {

        IntPtr hdc = GetDC(IntPtr.Zero);

 

               uint size = 12;

               byte[] vpm = new byte[size];

                      

               //structure 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);

 

               ExtEscapeSet(hdc, SETPOWERMANAGEMENT, size, vpm, 0, IntPtr.Zero);

               }

 

        [DllImport("coredll", EntryPoint="ExtEscape")]

        private static extern int ExtEscapeSet(

               IntPtr hdc,

               uint nEscape,

               uint cbInput,

               byte[] lpszInData,

               int cbOutput,

               IntPtr lpszOutData

               );

 

        [DllImport("coredll")]

        private static extern IntPtr GetDC(IntPtr hwnd);

 

}

       

       

 

public enum VideoPowerState : uint

{

        VideoPowerOn = 1,

        VideoPowerStandBy,

        VideoPowerSuspend,

        VideoPowerOff

}

 


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有