惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
T
Threatpost
IT之家
IT之家
腾讯CDC
博客园 - 【当耐特】
博客园 - 聂微东
月光博客
月光博客
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - Franky
博客园 - 叶小钗
S
Security @ Cisco Blogs
雷峰网
雷峰网
N
News and Events Feed by Topic
Attack and Defense Labs
Attack and Defense Labs
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
SegmentFault 最新的问题
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
Lohrmann on Cybersecurity
Project Zero
Project Zero
www.infosecurity-magazine.com
www.infosecurity-magazine.com
宝玉的分享
宝玉的分享
阮一峰的网络日志
阮一峰的网络日志
The Last Watchdog
The Last Watchdog
Apple Machine Learning Research
Apple Machine Learning Research
W
WeLiveSecurity
C
Cisco Blogs
T
Tenable Blog
Schneier on Security
Schneier on Security
爱范儿
爱范儿
美团技术团队
V2EX - 技术
V2EX - 技术
V
V2EX
Google Online Security Blog
Google Online Security Blog
Last Week in AI
Last Week in AI
Security Archives - TechRepublic
Security Archives - TechRepublic
The Hacker News
The Hacker News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
博客园_首页
H
Hacker News: Front Page
量子位
N
News | PayPal Newsroom
大猫的无限游戏
大猫的无限游戏

博客园 - ruinet

WCF通用服务请求类 使用MVP模式实现B/S和C/S平台的功能通用 WCF中使用扩展行为来验证连接的用户 Microsoft.Practices.Unity依赖注入使用实例 简洁的Asp.net菜单控件 Windows Mobile无线打印的实现 使用HTML,CSS快速导出数据到Excel 软件技术网站精选 CakePHP架构入门 升级Sql Server 2000到Sql Server 2005中要注意的问题 asp.net web开发综合技能 编写第一个Silverlight程序 Saas学习 在Windows Mobile上控制输入法 - ruinet - 博客园 在Windows Mobile创建桌面快捷方式 在仿真设备中使用主机网络 CSS,JavaSript,Html实用小代码 使用Ajax控件引发性能问题 智能移动项目打包发布经验交流
重启PocketPC移动设备
ruinet · 2007-10-30 · via 博客园 - ruinet

2007-10-30 16:54  ruinet  阅读(618)  评论()    收藏  举报

PocketPC运行程序经常由于某些不确定的因素,导致程序就死在那里了.但在PocketPC上又没有象桌面Windows一样的任务管理器.所有出现了此问题要么就等个半天,要么就硬重启.下面给大家介绍一段软重启的代码.看过就可以直接拿来使用.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace ResetPocketPC
{
  
class ResetPocketPC
  
{
    
public const uint FILE_DEVICE_HAL = 0x00000101;
    
public const uint METHOD_BUFFERED = 0;
    
public const uint FILE_ANY_ACCESS = 0;
    
public   uint CTL_CODE(uint DeviceType, uint Function, uint Method, uint Access)
    
{
      
return ((DeviceType << 16| (Access << 14| (Function << 2| Method);
    }

    [DllImport(
"Coredll.dll")]
    
public extern static uint KernelIoControl
    (
        
uint dwIoControlCode,
        IntPtr lpInBuf,
        
uint nInBufSize,
        IntPtr lpOutBuf,
        
uint nOutBufSize,
        
ref uint lpBytesReturned
    );
    
//调用此方法软重启
    public  uint ResetPocketPC()
    
{
      
uint bytesReturned = 0;
      
uint IOCTL_HAL_REBOOT = CTL_CODE(FILE_DEVICE_HAL, 15,METHOD_BUFFERED, FILE_ANY_ACCESS);
      
return KernelIoControl(IOCTL_HAL_REBOOT, IntPtr.Zero, 0,IntPtr.Zero, 0ref bytesReturned);
    }


  }

}

//调用
 private void button1_Click(object sender, EventArgs e)
    
{
      DialogResult r 
= MessageBox.Show(
        
"你确定要重启吗?",
        
"Test",
        MessageBoxButtons.YesNo,
        MessageBoxIcon.Question,
        MessageBoxDefaultButton.Button2
    );

      
if (r == DialogResult.Yes)
      
{
        ResetMobile RsMobile 
= new ResetMobile();
        RsMobile.ResetPocketPC();

      }


    }