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!

*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.

Jobs

Tips -N- Tricks

How to interact with Windows CE/PocketPC? by wgcs
Posted: 26 Jun 03

You can fully interact with Windows CE / PocketPC from within VFP, even beyond the capabilities of ActiveSync.

You can write files, read files, copy & delete files, create databases, read databases, access the registry, execute programs, manipulate windows, and more!!

All the functions (as far as I know) for dealing with Windows CE are stored in RAPI.DLL.  It seems that most, if not all, start with "Ce" when being executes as an RPC from the desktop/host Windows OS: though they may be documented as "WriteFile", it would be called from VFP as "CeWriteFile".

Many of these Api functions require Structures... for one example of how to use structures, see: http://fox.wikis.com/wc.dll?Wiki~ApiStructureClass

Here is an example of how to Write a text file to a Windows CE device (PocketPC runs on Windows CE):

* Author: William GC Steinford
*   Date: June 26, 2003
* Code to write a text file on device:
hnd=CeCreateFile('Storage Card\My Documents\Text\test.txt')
?hnd  
if hnd<>-1
  ?cewritefile(hnd,"Hello Windows CE!!")
  ?ceCloseHandle(hnd)
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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

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