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

推荐订阅源

V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
Arctic Wolf
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
P
Proofpoint News Feed
S
Schneier on Security
The Cloudflare Blog
Security Latest
Security Latest
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
K
Kaspersky official blog
Latest news
Latest news
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
F
Fortinet All Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
美团技术团队
博客园 - 叶小钗
H
Help Net Security
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
WordPress大学
WordPress大学
Cloudbric
Cloudbric
IT之家
IT之家
Last Week in AI
Last Week in AI
S
Securelist
Google Online Security Blog
Google Online Security Blog
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
L
LINUX DO - 最新话题
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
宝玉的分享
宝玉的分享
博客园 - Franky
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
B
Blog

博客园 - 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();

      }


    }