教程集 www.jiaochengji.com
教程集 >  操作系统  >  windows  >  正文 桌面端的移动运算(二)

桌面端的移动运算(二)

发布时间:2019-12-11   编辑:jiaochengji.com
教程集为您提供桌面端的移动运算(二)等资源,欢迎您收藏本站,我们将为您提供最新的桌面端的移动运算(二)资源
Working with the RAPI Class
为了简化RAPI类的操作,我将添加一个using声明到示例程序的C#版本,或添加一个Imports声明到VB.NET中,示例如下:
[VC#.NET]
using OpenNETCF.Desktop.Communication;
[VB.NET]
Imports OpenNETCF.Desktop.Communication
另外,我将添加一个单独的module-level变量,myrapi,用于保存一个RAPI类的实例。
[VC#.NET]
// Declare an instance of the RAPI object.
RAPI myrapi;
[VB.NET]
' Declare an instance of the RAPI object.
Dim WithEvents myrapi As New rapi
Connecting to the Device
当你的桌面程序使用RAPI类时,第一步是要与设备建立一个连接。
注意:在桌面程序中使用RAPI必须要有一个PC与设备之间的激活的ActiveSync连接。
在这篇文章包含的示例程序中,在Form_Load事件中将连接到设备。为了连接到设备,你使用RAPI类的Connect方法。正如下面代码所演示的,我紧接着检查了RAPI类的DevicePresent属性,来校验连接是否成功。
[VC#.NET]
try
// Connect to the device.
{
myrapi.Connect();
while (! myrapi.DevicePresent)
{
MessageBox.Show("Please connect your device to your PC using
ActiveSync and before clicking the OK button.",
"No Device Present");
myrapi.Connect();
}
}

catch (Exception ex)
{
MessageBox.Show("The following error occurred while attempting
to connect to" " your device - " ex.Message,
"Connection Error");
Application.Exit();
}
[VB.NET]
Try
' Connect to the device.
myrapi.Connect()
Do While Not myrapi.DevicePresent

您可能感兴趣的文章:
桌面端的移动运算(一)
桌面端的移动运算(二)
桌面端的移动计算(四)
桌面端的移动运算(三)
CentOS 5.5 使用VNC进行远程配置
学习远程桌面命令mstsc的运用
Win2003远程桌面管理技巧
修改远程桌面端口号的vbs代码
学会php能做什么工作?
Win2003无法识别USB2.0或USB3.0移动硬盘设备解决办法

[关闭]
~ ~