HOWTO:Turn Off PDA Display while your application is running.(VB.Net/c#+.Net CF+PPC2003) from CodeProject
2005-08-03 23:09
597 查看
Core code for VB.NET:
using System;
using System.Runtime.InteropServices;
Namespace OpenNETCFnamespace OpenNETCF
{
/// <summary>
/// Summary description for Video.
/// </summary>
public Class Videoclass 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 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);
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 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);
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 VideoPowerStateenum VideoPowerState : uint
{
VideoPowerOn = 1,
VideoPowerStandBy,
VideoPowerSuspend,
VideoPowerOff
}
using System;
using System.Runtime.InteropServices;
Namespace OpenNETCFnamespace OpenNETCF
{
/// <summary>
/// Summary description for Video.
/// </summary>
public Class Videoclass 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 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);
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 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);
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 VideoPowerStateenum VideoPowerState : uint
{
VideoPowerOn = 1,
VideoPowerStandBy,
VideoPowerSuspend,
VideoPowerOff
}
相关文章推荐
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- This event supports the .NET Framework infrastructure and is not intended to be used directly from your code?继承自VScrollbar的自定义winform控件,某些事件不触发的问题(Winform控件开发学习)
- [导入]How can I run another application or batch file from my Visual C# .NET code?
- [CodeProject每日一荐] TaskbarNotifier: 可换肤的 MSN Messenger-like 风格窗体( C# & VB.NET)
- PDA Battery Info (VB.Net+.Net CF) Source Code
- [CodeProject每日一荐] TaskbarNotifier: 可换肤的 MSN Messenger-like 风格窗体( C# & VB.NET)
- This code compacts and repairs an MS Access database from a C# .NET application
- [CodeProject每日一荐] PopupNotifier: 一个Office 2003风格的通知控件(VB.NET)
- 《C# vs.VB.NET:Choosing Your .NET Tool》观感
- 酷!用VB或VB.NET开发S60,PPC,PALM等各种智能手机/PDA的应用程序
- ASP.NET Razor - C# and VB Code Syntax
- ASP.NET Alerts: how to display message boxes from server-side code?
- JavaApplet-Application Blocked..Your security setting have blocked an untrusted application from running..
- 解决报错"Your security system have blocked an application with expired or not yet valid certificate from running"
- How to resolve "your security settings have blocked an untrusted application from running" in Mac
- Calling Managed .NET C# COM Objects from Unmanaged C++ Code
- Your project contains errors,please fix them before running your application
- Your project contains error(s),please fix them before running your application
- 解决方案your project contains error s please fix them before running your application
- Tip #8 在app_code文件夹内同时使用C#和VB.Net