Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

smrtelnik

Programmer
Apr 6, 2005
6
SK
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top