winCE与本地电脑之间的文件传递

该博客介绍了一个在Windows CE(WinCE)设备与本地电脑之间进行文件传输的实现方法。通过调用rapi.dll中的API函数,实现了文件的上传(CopyFileToPDA)和下载(CopyFileToPC)功能,包括文件的创建、打开、读取、写入和关闭操作。在过程中,使用了手动重置事件(ManualResetEvent)来初始化设备,并进行了错误处理。
摘要由CSDN通过智能技术生成

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;

namespace pctoce
{
    public partial class Form1 : Form
    {
        // 声明要引用的API
        [DllImport("rapi.dll")]private static extern uint CeRapiUninit();
        [DllImport("rapi.dll")]private static extern uint CeRapiInitEx(ref RAPIINIT pRapiInit);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] internal static extern int CeDeleteFile(string FileName);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] internal static extern int CeCloseHandle(IntPtr hObject);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] internal static extern int CeWriteFile(IntPtr hFile, byte[] lpBuffer, int nNumberOfbytesToWrite, ref int lpNumberOfbytesWritten, int lpOverlapped);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode, SetLastError=true)]internal static extern IntPtr CeCreateFile(string lpFileName, uint dwDesiredAccess,int dwShareMode,int lpSecurityAttributes,int dwCreationDisposition,int dwFlagsAndAttributes,int hTemplateFile);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] public static extern int CeFindFirstFile(string lpFileName,ref CE_FIND_DATA lpFindFileData);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] internal static extern int CeReadFile(int hFile,byte[] lpBuffer,int lpOverlapped,out int laji,int gouride);
        [DllImport("rapi.dll", CharSet=CharSet.Unicode)] internal static extern int CeGetFileSize(int hFile, int lpOverlapped);

        public struct CE_FIND_DATA
        {
        public int dwFileAttributes

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值