1、进程管理
:在NET Compact Framework里进程管理的函数相对要比net Framework里要简化,不过仍然可以比较好的控制程序进程。
A.启动进程:在启动进程后返回进程的id
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->///
<summary>
///
启动进程
///
</summary>
///
<param name="fileName">
启动文件的目录路径
</param>
///
<returns>
返回启动进程的进程ID
</returns>
public
static
int
StartProcess(
string
fileName)
{
int
progressID
=
0
;
try
{
//
这个目录是动态的
progressID
=
System.Diagnostics.Process.Start(fileName).Id;
return
progressID;
}
catch
//
(Exception ex)
{
//
throw ex;
return
0
;
}
}
B.获取当前进程的ID
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->///
<summary>
///
获取当前进程ID
///
</summary>
public
static
int
GetCurrentProcessID()
{
Process currentProcess
=
Process.GetCurrentProcess();
int
CurrentProcessID
=
currentProcess.Id;
return
CurrentProcessID;
}
C.终止当前进程
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->///
<summary>
///
终止当前进程
///
</summary>
public
static
void
KillCurrentProcess()
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
D.通过进程ID来终止进程
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->///
<summary>
///
终止进程
///
</summary>
///
<param name="progressID">
进程ID
</param>
///
<returns>
true 表示终止成功,反之表示失败
</returns>
public
static
bool
KillProcess(
int
progressID)
{
try
{
System.Diagnostics.Process.GetProcessById(progressID).Kill();
return
true
;
}
catch
//
(Exception ex)
{
//
throw ex;
return
false
;
}
}
2、窗体管理。在NET Compact
Framework(2.0)的窗体类(System.Windows.Forms.Form))虽然提供WindowsState属性,这个属性是
FormWindowState 枚举类型,在枚举中只有Normal 和
Maximized,不过不能通过Maximized来控制窗体最小,同时也无法控制窗体的关闭。要是实现关闭和最小化只能通过调用api来实现。下面是
有关代码:
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->[DllImport(
"
coredll.dll
"
)]
private
extern
static
bool
ShowWindow(IntPtr hWnd,
int
nCmdShow);
[DllImport(
"
coredll.dll
"
)]
private
static
extern
IntPtr FindWindow(
string
lpClassName,
string
lpWindowName);
///
最小化窗体
public
static
void
WindowsMin(
string
frmTextName)
{
IntPtr hwnd
=
FindWindow(
null
, frmTextName);
ShowWindow(hwnd,
6
);
}
///
隐藏窗体
public
static
void
WindowHide(
string
frmTextName)
{
IntPtr hwnd
=
FindWindow(
null
, frmTextName);
ShowWindow(hwnd,
0
);
}
3、重启和关闭操作系统。同样是调用api来完成。
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
[DllImport(
"
Aygshell.dll
"
)]
static
extern
bool
ExitWindowsEx(
uint
uFlags,
int
dwReserved);
private
const
uint
EWX_REBOOT
=
2
;
private
const
uint
EWX_POWEROFF
=
8
;
///
重启操作系统
public
static
void
RootWindows()
{
ExitWindowsEx(EWX_REBOOT,
0
);
}
///
关闭操作系统
public
static
void
ShutDownWindows()
{
ExitWindowsEx(EWX_POWEROFF,
0
);
}
以上代码的运行环境和开发环境:windows mobile5.0 +ppc sdk +vs2005
本文地址:http://www.watch-life.net/windows-mobile/process-window-form-system-manager.html
分享到:
相关推荐
Windows Mobile 5.0 Final Release Documentation Windows Mobile 5.0 开发文档最终版,--2007/2
Windows Mobile 5.0 SDK 下载地址收藏
升级windows mobile 5.0
Windows mobile5.0仿真器
Windows Mobile 5.0开发
WindowsMobile5 源码WindowsMobile5 源码WindowsMobile5 源码WindowsMobile5 源码
Windows Mobile 5.0 三十几个经典手机软件开发源码 希望对大家有帮助
本文结合作者自学过程,从一个完全没接触过移动平台开发的新手的角度讲解基于Windows Mobile 5.0平台的GPS应用程序的开发过程.体验使用Visual C#开发移动应用程序的高效率.
单击按钮 就能打开win mobile 5.0 系统 手机的摄像头,从而能完成摄像拍照,并保存
车主宝典软件是为城市车主用户量身订做的一套基于手机平台运行的优秀手机客户端软件。 集实时路况、消费打折、资讯浏览、互动娱乐、便民查询、汽车知识为一体的服务于广大车主用户的综合性服务平台产品。...
Windows Mobile 5.0 Final Release Documentation Windows Mobile 5.0 开发文档最终版,--2007/2
自己c#写的手机时间更新软件,时间采用的是国家授时中心标准时间+时间补尝。流量更省(每次时间更新)。 操作方法:直接运行程序。首先获取时间,然后再更新时间。
windows mobile 5.0 批量删除contact
SAMSUNG2440 Windows mobile 5.0 BSP,support camera
Windows Mobile 5.0 Final Release Documentation Windows Mobile 5.0 开发文档最终版,--2007/2
Windows Mobile 5.0 Final Release Documentation Windows Mobile 5.0 开发文档最终版,--2007/2
Windows Mobile 5.0模拟文件,.bin格式,使用方法主程序中有,一看就懂~ 主程序地址:http://download.csdn.net/source/1000677
Optional Windows Mobile 5.0 Server Components
Image Manipulation in Windows Mobile 5.0
Windows Mobile5.0开发新特性 更多资源请访问http://www.59186618.com