×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Problems with copying/sending data from desktop PC to Pocket PC.

Problems with copying/sending data from desktop PC to Pocket PC.

Problems with copying/sending data from desktop PC to Pocket PC.

(OP)
Greetings to all.
I have big problem. I need to send some files from my application on desktop PC to POCKET PC (with Windows CE5).
I try to use rapi.dll, but I don't know how. I use VFP 9.0. This is code, I found here on Tek-Tips:

CODE

#DEFINE GENERIC_READ 0x80000000
#DEFINE FILE_ATTRIBUTE_NORMAL 0x00000080
#DEFINE GENERIC_WRITE 0x40000000
#define CREATE_ALWAYS 2

hnd=CeCreateFile('My Documents\test.txt')
if hnd<>-1
  ?cewritefile(hnd,"Hello Windows CE!!")
  ?ceCloseHandle(hnd)
else
   return
endif


* Api function wrappers follow:
FUNCTION CeCreateFile( pcName )
  DECLARE LONG CeCreateFile IN RAPI.DLL AS _ceCreateFile ;
    STRING @ LPCTSTR_lpFileName, ;
    LONG DWORD_dwDesiredAccess,  ;
    LONG DWORD_dwShareMode,      ;
    LONG Ignored_LPSECURITY_ATTRIBUTES_lpSecurityAttributes, ;
    LONG DWORD_dwCreationDispostion,  ;
    LONG DWORD_dwFlagsAndAttributes,  ;
    LONG Ignored_HANDLE_hTemplateFile
  LOCAL lnHnd, lcStr
  lcStr = StringToUnicode(pcName)
  lnHnd = _ceCreateFile( @lcStr, BitOr(GENERIC_READ,GENERIC_WRITE), ;
    0,0,CREATE_ALWAYS,0,0 )
  RETURN lnHnd
ENDFUNC
FUNCTION CeCloseHandle( pnHnd )
  DECLARE LONG CeCloseHandle IN RAPI.DLL AS _ceCloseHandle ;
    LONG nHnd
  RETURN _ceCloseHandle(pnHnd)=1
ENDFUNC
FUNCTION CeWriteFile( pnHnd, pcStr )
  DECLARE LONG CeWriteFile IN RAPI.DLL AS _ceWriteFile ;
    LONG     HANDLE_hFile, ;
    STRING @ LPCVOID_lpBuffer, ;
    LONG     DWORD_nNumberOfBytesToWrite, ;
    LONG   @ LPDWORD_lpNumberOfBytesWritten, ;
    LONG     Ignored_LPOVERLAPPED_lpOverlapped
  LOCAL lnWritten
  lnWritten = 0
  _ceWriteFile( pnHnd, @pcStr, len(pcStr), @lnWritten, 0 )
  RETURN lnWritten
ENDFUNC
PROCEDURE UnicodeToString( pcStr )
  LOCAL lcSkel
  lcSkel = StrConv( pcStr,  6 ) && Double Byte <- Unicode
  lcSkel = StrConv( lcSkel, 2 ) && Single byte <- Double Byte
  RETURN LEFT(lcSkel, MAX(AT(chr(0),lcSkel)-1,0) )
ENDPROC
PROCEDURE StringToUnicode( pcStr )
  LOCAL lcSkel
  lcSkel = StrConv( pcStr,  1 ) && Single byte -> Double Byte
  lcSkel = StrConv( lcSkel, 5 ) && Double Byte -> Unicode
  RETURN lcSkel+chr(0)
ENDPROC

But function cecreatefile returns handle -1.
Don't you know, where is problem?
Thanks for all answers.

Brano Ondrejka

P.S.: I have ActiveSync 4.2 on my desktop PC.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close