Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Pocket PC: retrieving data from the Contacts Database
Using Video Capture: enumerating installed capture drivers
Reading STARTUPINFO structure for the current VFP session
Retrieving the name and type of all available RAS-capable devices
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
Determining if an Active Network Connection is Available
Pocket PC: creating new database in the Object Store and copying Contacts Database records into it
Retrieving the path of the printer-driver directory and printer-processor directory
Retrieving configuration information for the specified server (Win98/Me)
Pocket PC: creating backup for the System Registry
PocketPC: creating directories and files
Retrieving list of all active RAS connections
List of ODBC drivers installed (read from the [ODBC Drivers] section)
Testing Transparent Menu Class with top-level form (requires VFP9)
Using ActiveX control for adding a menu directly to a FoxPro MDI form
Using Custom FTP class (DEFINE CLASS ftp As Custom)
Changing system colors
How to intercept window messages sent to VFP form
Creating ESE database and table
How to perform Base64 encoding/decoding using Cryptography API Functions
Pocket PC: System Registry Viewer
Setting the last-error code for the FoxPro
WAV file recorder
Accessing a CD device (cdaudio) with Multimedia Command Strings
Pocket PC: retrieving data from the Contacts Database

User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
More code examples    Listed functions    Add comment     W32 Constants      Translate this page Printer friendly version of this code sample
Before you begin:
Start ActiveSync and establish connection with your Pocket PC before the testing.

The code is based on base RAPI Database class and on custom RAPI Database class for operating with the Object Store Databases. Download both class modules prior to testing this code.
SET PROCEDURE TO clsRapi ADDITIVE
SET PROCEDURE TO clsRapiDb ADDITIVE

LOCAL oRapi As TrapiDb
oRapi = CREATEOBJECT("TrapiDb")

IF NOT oRapi.Connected
    = MESSAGEBOX("Mobile device is unavailable.     ", 48, "Error")
    RETURN
ENDIF

LOCAL db, nIndex, firstname, middlename, lastname, email,;
    cellphone, homephone, note23, ex As Exception

TRY
    db = oRapi.databases.GetDatabase("Contacts Database")
*    db = oRapi.databases.GetDatabase("dbContactsCopy")

    IF db.OpenDatabase()
        CREATE CURSOR contacts (firstname C(15), middlename C(15),;
            lastname C(25), cellphone C(20), homephone C(20),;
            email C(50), note23 M)

        FOR nIndex=0 TO db.dbreccount-1
            db.goto(nIndex)

            firstname = FromUnicode(db.props.GetValue("14854", ""))
            middlename = FromUnicode(db.props.GetValue("16420", ""))
            lastname = FromUnicode(db.props.GetValue("14865", ""))
            email = FromUnicode(db.props.GetValue("16515", ""))
            cellphone = FromUnicode(db.props.GetValue("14876", ""))
            homephone = FromUnicode(db.props.GetValue("14857", ""))
            note23 = db.props.GetValue("23", "")

            INSERT INTO contacts VALUES (;
                m.firstname, m.middlename, m.lastname,;
                m.cellphone, m.homephone, m.email, m.note23)
        ENDFOR
        db.CloseDatabase
    ELSE
        = MESSAGEBOX("Could not open requested database.     ",;
            48, "Error")
    ENDIF

CATCH TO ex
    = MESSAGEBOX("Error: " + TRANSFORM(ex.ErrorNo) + ". " +;
        ex.Message + ".     ", 48, "Error")
ENDTRY

IF USED("contacts")
    SELECT contacts
    GO TOP
    BROWSE NORMAL NOWAIT
ENDIF



User rating: 0/10 (0 votes)
Rate this code sample:
  • ~
1552 bytes  
Created: 2004-07-02 16:56:56  
Modified: 2009-02-15 19:31:15  
Visits in 7 days: 22  
Listed functions:
Printer friendly API declarations
My comment:
To make it short: the mobile database model is quite different from the relational model. The Contacts Database records retrieved in this example most likely will have various number of properties per record (those we call "fields" in FoxPro). Though each record has unique object identifier assigned by the system.

What RAPI calls a database is actually a table. And RAPI database volume has some resemblance to database as storage of data and integrity log.

There is no table header with field parameters. Instead of field names the property identifiers are used. For the Contacts Database, for example, identifier 14876 means "Mobile Phone Number". The property is described by identifier, data type, flags and value.

It looks like any application working with the Contacts Database must be aware of this particular PropertyID to Caption translation as well as of the others:

14856=Work Tel
14857=Home Tel
14876=Mobile Tel
14878=Car Tel
14884=Work Fax
14885=Home Fax
14895=Home2 Tel
16388=Asst. Tel
16391=Work2 Tel
16393=Pager
16458=Other Street
16459=Other City
16460=Other State
16461=Other Zip
14853=Suffix
14854=First Name
14865=Last Name
14870=Company
14871=Title
14872=Department
14873=Office Location
14877=Radio
16386=Assistant
16390=Children
16392=Web Page
16394=Spouse
16403=File As
16419=Mr/Mrs/Dr
16420=Middle Name
16448=Home Street
16449=Home City
16450=Home State
16451=Home Zip
16452=Home Country
16453=Office Street
16454=Office City
16455=Office State
16456=Office Zip
16457=Office Country
16462=Other Country
16515=Email1
16531=Email2
16547=Email3

These property ids have some resemblance to WordPerfect Address Book codes. Other than that I have no idea where these values came from and if any White Paper exists on them.

API functions used in the base class:
CeCloseHandle
CeEnumDBVolumes
CeFindFirstDatabaseEx
CeFindNextDatabaseEx
CeGetLastError
CeOidGetInfoEx
CeOpenDatabase
CeRapiInitEx
CeRapiUninit
CeReadRecordProps
CeSeekDatabase
LocalFree
WaitForSingleObject


#kwd: sln_pocketpc.
Word Index links for this example:
Translate this page:
  Spanish    Portuguese    German    French    Italian  
FreeTranslation.com offers instant, free translations of text or web pages.
User Contributed Notes:
There are no notes on this subject.


Copyright 2001-2018 News2News, Inc. Before reproducing or distributing any data from this site please ask for an approval from its owner. Unless otherwise specified, this page is for your personal and non-commercial use. The information on this page is presented AS IS, meaning that you may use it at your own risk. Microsoft Visual FoxPro and Windows are trade marks of Microsoft Corp. All other trademarks are the property of their respective owners. 

Privacy policy
Credits: PHP (4.4.9), an HTML-embedded scripting language, MySQL (5.6.39), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (50.19.34.255)
42 sec.Function: 'CeSeekDatabase'
Function group: 'Remote Application Programming (RAPI)'
1 min.Function: 'waveInGetDevCaps'
Function group: 'Windows Multimedia'
1.33 min.Function: 'waveOutSetVolume'
Function group: 'Windows Multimedia'
1.62 min.
Function group: 'Windows Multimedia'
1.98 min.Function: 'HeapReAlloc'
Function group: 'Memory Management'
2.27 min.All Functions
2.9 min.Function: 'ntohs'
Function group: 'Windows Sockets 2 (Winsock)'
3.22 min.Function: 'send'
Function group: 'Windows Sockets 2 (Winsock)'
3.47 min.Example: 'How to view icons stored in executable files (Icon Viewer)'
Google
Advertise here!