Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 7474|回复: 17

Lazarus如何在WINCE上向WINXP上传数据

[复制链接]
回帖奖励 1 RMB金钱 回复本帖可获得 1 RMB金钱奖励! 每人限 1 次(中奖概率 10%)

该用户从未签到

发表于 2012-1-16 16:53:34 | 显示全部楼层 |阅读模式
现在需要一个数据上传或数据下载的功能,但不知道可以利用什么API函数或组件实现WINCE向WINXP上传 或者把WINXP的数据下载到WINCE上,求解高手
给出解答。
回复

使用道具 举报

该用户从未签到

发表于 2012-1-16 23:05:43 | 显示全部楼层
socket可以不?
用indy试试看
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-1-17 09:43:15 | 显示全部楼层
简单啦,用 M$的 Active/sync 就可以了
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-2-1 09:53:56 | 显示全部楼层
就是,同步软件赛  
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-2-2 16:10:09 | 显示全部楼层
unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  ComCtrls,windows;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    ProgressBar1: TProgressBar;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

  function   copyFileToDevice(LocalFile:   string;   RemoteFile:   string;   OverWrite:   Boolean):boolean;
  function   copyFileFromDevice(LocalFile:   string;   RemoteFile:   string):Boolean;

  function   CeRapiInit():   integer;   stdcall;   external   'RAPI.DLL';
  function   CeRapiUninit():   integer;   stdcall;   external   'RAPI.DLL';

  function   CeCreateFile(lpFileName:   WideString;   dwDesiredAccess:   cardinal;   dwShareMode:   cardinal;   lpSecurityAttributes:   pSecurityAttributes;
      dwCreationDisposition:   cardinal;   dwFlagsAndAttributes:   cardinal;   hTemplateFile:   cardinal):   cardinal;   stdcall;   external   'RAPI.DLL';
  function   CeReadFile(hFile:   cardinal;   var   lpBuffer;   nNumberOfBytesToRead:   cardinal;
      var   lpNumberOfBytesRead:   cardinal;   lpOverlapped:   poverlapped):   Boolean;   stdcall;   external   'RAPI.DLL';

  function   CeWriteFile(hFile:   cardinal;   const   lpBuffer;   nNumberOfBytesToWrite:   cardinal;
      var   lpNumberOfBytesWritten:   cardinal;   lpOverlapped:   poverlapped):   Boolean;   stdcall;   external   'RAPI.DLL';
  function CeGetFileSize(hFile:cardinal;var lpFileSizeHigh:dword ):integer;stdcall;external 'RAPI.DLL';
  function   CeCloseHandle(IntPtr:   thandle):   integer;   stdcall;   external   'RAPI.DLL';


implementation

{$R *.lfm}

{ TForm1 }

function   copyFileToDevice(LocalFile:   string;   RemoteFile:   string;   OverWrite:   boolean):boolean;
  var   fs:   TFileStream;
      ahandle:   thandle;
      FTempBuffer:   array[0..$1000]   of   byte;
      n,   m:   integer;
      nwrite:   dword;
      IsOverWrite:   integer;
  begin
      result   :=   false;
      if   (CeRapiInit()   <>   0)   then
          exit;
      ahandle   :=   0;

      if   OverWrite   then
          IsOverWrite   :=   2   else
          IsOverWrite   :=   1;
      // function   CeCreateFile(lpFileName:   WideString;
      // dwDesiredAccess:   cardinal;   dwShareMode:   cardinal;   lpSecurityAttributes:   pSecurityAttributes;
      // dwCreationDisposition:   cardinal;   dwFlagsAndAttributes:   cardinal;   hTemplateFile:   cardinal):
      // cardinal;

      //                                  $40000000               2
      //CeCreateFile(PWideChar(ToFile), GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_NEW, 0, 0);

      ahandle   :=   CeCreateFile(RemoteFile,   $40000000,   2,   nil,   IsOverWrite,   $80,   0);

      if   ahandle   =   -1   then
      begin
          result:=false;
          CeRapiUninit();
          exit;
      end;

      if   fileexists(localfile)   then
          fs   :=   tfileStream.Create(localfile,   fmOpenRead)   else
      exit;
      n   :=   sizeof(FTempBuffer);
      m   :=   fs.Size;

      form1.ProgressBar1.Max :=m;

      try
          while   fs.Position   <   fs.Size   do
          begin
              form1.ProgressBar1.Position :=fs.Position;
              if   m   <   n   then
                  n   :=   m;
              fs.Read(FTempBuffer,   n);
              if   not   CeWriteFile(aHandle,   FTempBuffer,   n,   nwrite,   nil)   then
                  break;
              m   :=   m   -   n;
          end;
      finally
          CeCloseHandle(ahandle);
      end;

      if   fs.Position   =   fs.Size     then
      result   :=   true;
      fs.Free;
      CeRapiUninit();
  end;

  function   copyFileFromDevice(LocalFile:   string;   RemoteFile:   string):boolean;
  var   fs:   TFileStream;
      ahandle:   thandle;
      FTempBuffer:   array[0..$1000]   of   byte;
      nwrite,nRead,filelength:   dword;
  begin
      result   :=   true;

      if   (CeRapiInit()   <>   0)   then
          exit;
      ahandle   :=   0;

      ahandle   :=   CeCreateFile(RemoteFile,   $80000000,   0,   nil,   3,   $80,   0);

      if   ahandle   =   -1   then
      begin
          showmessage('在设备上创建文件失败!');
          CeRapiUninit();
          result   :=   false;
          exit;
      end;
      form1.ProgressBar1.Max :=CeGetFileSize(ahandle,filelength);
      if   fileexists(localfile)   then
          deletefile(PChar(localfile));

      fs:=tfileStream.Create(localfile,fmCreate);

      //
      CeReadFile(ahandle,FtempBuffer,sizeof(fTempBuffer),nRead,nil);
      while   nRead>0   do
      begin
          application.ProcessMessages;
          form1.ProgressBar1.Position := form1.ProgressBar1.Position +nRead;
          fs.Write(fTempBuffer,nRead);
          if   not   CeReadFile(ahandle,FtempBuffer,sizeof(fTempBuffer),nRead,nil)   then
          begin
              result:=false;
              break;
          end;
      end;

      CeCloseHandle(ahandle);
      fs.Free;
      CeRapiUninit();
  end;


procedure TForm1.FormCreate(Sender: TObject);
begin

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   copyFileFromDevice(edit1.text,edit2.text);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  copyFileToDevice(edit1.text,edit2.text,true);
  showmessage('操作成功!');
end;

end.
---------------------------------------------
  参考他人代码,转帖网上的。

加了点自己琢磨的。
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-2-3 09:38:33 | 显示全部楼层
Socket Select模型。

同步软件?还是算了吧,一般wince都是移动设备,难道还要连着数据线?

另外不知道你的要求是什么?wince设备做服务器还是客户端。
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-3-7 21:54:34 | 显示全部楼层
关注一下,我也想了解
回复 支持 反对

使用道具 举报

该用户从未签到

发表于 2012-3-25 22:44:18 | 显示全部楼层
我也来顶一顶。
回复 支持 反对

使用道具 举报

  • TA的每日心情
    开心
    2016-10-8 22:51
  • 签到天数: 1 天

    [LV.1]初来乍到

    发表于 2012-4-2 21:06:49 | 显示全部楼层
    我也在找这方面资料啊
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2016-10-8 22:51
  • 签到天数: 1 天

    [LV.1]初来乍到

    发表于 2012-4-28 02:34:02 | 显示全部楼层
    webservice http 走soap协议
    回复 支持 反对

    使用道具 举报

    *滑块验证:

    本版积分规则

    QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

    GMT+8, 2025-5-2 23:29 , Processed in 0.115182 second(s), 11 queries , Redis On.

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表