PDA . PC 相互操作

C#Form与Activesync快速拨打电话程序,Windows Mobile与电脑同步

 

OpenNETCF.Desktop.Communication接口的使用,以及对手机与电脑的互操作

在 OpenNETCF.Desktop.Communication 命名空间中提供的类 

说明

ActiveSync

提供对 Microsoft ActiveSync 底层功能的访问。

AutoStartApps

提供配置 ActiveSync 会话开始时运行的应用程序的功能及相关信息。

FileInformation

描述 FindFirstFile 和 FindNextFile 方法返回的文件信息结构。

FileList

FileInformation 类的集合。桌面应用程序经常用它查询和管理连接设备的文件结构。

RAPI

提供对基础 RAPI 函数的简便包装。

RAPIException

定义 RAPI 类发生的例外。

Registry

提供对基础 RegistryKey 类的访问,这些类反过来又用来访问并修改连接设备的注册表值和注册表子项。

RegistryKey

定义连接设备注册表中的一个项节点。

 

 

 

对开发移动应用程序有用的 RAPI 类方法。 
方法

说明

Connect

建立与设备的同步连接。

CopyFileFromDevice

将设备中的文件复制到 PC。

CopyFileOnDevice

将设备某个位置的文件复制到设备的另一新位置。

CopyFileToDevice

将 PC 中的文件复制到设备。

CreateDeviceDirectory

在设备中创建目录。

CreateProcess

启动设备中的应用程序。

DeleteDeviceFile

删除设备中的文件。

DeviceFileExists

检查设备中是否存在文件。

Disconnect

中断与设备的连接。

EnumFiles

提供与 FileName 参数提供的条件相匹配的 FileInformation 类数组列表。

GetDeviceCapabilities

检索设备的特定设备信息。

GetDeviceFileAttributes

检索特定设备文件的属性。

GetDeviceFileSize

检索设备文件的大小,以字节为单位。

GetDeviceFileTime

检索设备文件的日期时间。

GetDeviceMemoryStatus

检索设备的内存使用信息。

GetDeviceSystemFolderPath

检索到设备系统文件夹的路径。

GetDeviceSystemInfo

检索设备的系统详细信息。

GetDeviceSystemPowerStatus

检索设备的电源状态。

GetDeviceVersion

检索设备的操作系统版本。

MoveDeviceFile

将现有设备文件移到或重命名到一个新位置。

RemoveDeviceDirectory

删除设备中的目录。

SetDeviceFileAttributes

设置设备中文件的属性。

SetDeviceFileTime

设置设备中文件的日期时间。

 

以下是针对Windows Mobile系统的电脑拨打电话的程序,其中需要用到OpenNETCF.Desktop.Communication.dll以及Activesync

 

其中OpenNETCF.Desktop.Communication.dll下载地址:

http://download.csdn.net/detail/rczjp/4328268

 

Activesync下载地址:http://www.microsoft.com/downloads/zh-cn/details.aspx?FamilyID=9e641c34-6f7f-404d-a04b-dc09f8141141

 

 

 

以下是在电脑上拨打电话的代码:

using System;

using System.Windows.Forms;

using OpenNETCF.Desktop.Communication;

 

namespace WindowsMobile

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            RAPI myrapi = new RAPI();

            myrapi.Connect();

            try

            {

                if (phoneNum.Text == "")

                {

                    MessageBox.Show("请输入您要拨打的电话或手机号码!""错误");

                }

                else

                {

                    myrapi.CreateProcess(@"\Windows\FIHMakeCall.exe", phoneNum.Text);

                    MessageBox.Show("正在拨打中,请稍候...""成功");

                }

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message, "错误");

            }

        }

    }

}

 

当然还可以进行文件的同步,以及对文件的操作,如下:

电脑同步到手机

myrapi.CopyFileToDevice(源地址, 目标地址);

手机同步到电脑

myrapi.CopyFileFromDevice(源地址, 目标地址);

 

还可以看手机等设备的信息:

RAPI myrapi = new RAPI();

myrapi.Connect();

string info;

MEMORYSTATUS ms;

SYSTEM_INFO si;

SYSTEM_POWER_STATUS_EX sps;

OSVERSIONINFO vi;

 

// 检索系统信息。

myrapi.GetDeviceSystemInfo(out si);

 

// 检索设备操作系统版本号。

myrapi.GetDeviceVersion(out vi);

 

// 检索设备电源状态。

myrapi.GetDeviceSystemPowerStatus(out sps);

 

// 检索设备内存状态。

myrapi.GetDeviceMemoryStatus(out ms);

 

// 设置检索信息的格式。

info = "The connected device has an ";

switch (si.wProcessorArchitecture)

{

case ProcessorArchitecture.Intel:

     info += "Intel processor.\n";

     break;

case ProcessorArchitecture.MIPS:

     info += "MIPS processor.\n";

     break;

case ProcessorArchitecture.ARM:

     info += "ARM processor.\n";

     break;

default:

     info = "unknown processor type.\n";

     break;

}

 

info += "OS version: " + vi.dwMajorVersion + "." + vi.dwMinorVersion + "." +

vi.dwBuildNumber + "\n";

if (sps.ACLineStatus == 1)

     {

         info += "On AC power:YES\n";

     }

else

     {

         info += "On AC power:NO \n";

     }

     info += "Battery level: " + sps.BatteryLifePercent + "%\n";

     info += "Total memory: " + String.Format("{0:###,###,###}", ms.dwTotalPhys) +

     "\n";

 

MessageBox.Show(info);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值