Using Win32 functions in Visual FoxPro Image Gallery
Code examples:
Pocket PC: enumerating mounted database volumes and databases in the Object Store
Reading and setting explicit Application User Model ID for the current process (Win7)
Retrieving the command line for the VFP session
Using GetSysColor
How to drag a Form not using its Titlebar or Caption
Retrieving System Error message strings
Retrieving the name of the network resource associated with a local device
Changing pitch and speed of a wave file
Enumerating connections made to a shared resource for the local computer (WinNT only)
GDI+: loading image file, drawing on it, saving the result to another file
Pocket PC: retrieving data from the Contacts Database
Reading keys in the specified section of the Win.ini file
Retrieving information about all users currently logged on to the workstation (WinNT only)
Using Multimedia Command Strings to play MIDI files
How to retrieve information about a cache entry (Internet Explorer)
Retrieving configuration information for the specified server (Win2000/XP)
String representation for disk or memory capacity
Another way to go online (it is not about choosing an ISP)
How to test file attributes (key method for FileExists and DirectoryExists routines)
Memory usage info for current VFP session (WinNT only)
StrDup returns a pointer to the duplicate of a source VFP string
Listing INF files in a specified directory
Opening access to the Microsoft Internet functions for the application
The SQLGetProp() creates a bridge between Visual FoxPro and the ODBC API
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: 57  
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-2013 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.1.55-log), the Open Source standard SQL database, AceHTML Freeware Version 4, freeware HTML Editor of choice.   Hosted by Korax Online Inc.
Last Topics Visited (54.242.233.11)
1.97 hrs.Example: 'Using Extended MessageBox() Class'
 Function: 'NetApiBufferSize'
Function group: 'Network Management'
4.1 hrs.Function: 'GetPhysicalMonitorsFromHMONITOR'
 Example: 'Using the Semaphore object'
4.76 hrs.Example: 'Running MSDOS Shell as a child process with redirected input and output (smarter RUN command)'
 Function: 'RegDeleteKey'
6.15 hrs.Example: 'How to enumerate terminal servers within the specified Windows domain'
6.16 hrs.Function: 'WindowFromDC'
9.24 hrs.Example: 'Displaying animated images on FoxPro form with BitBlt and StretchBlt functions'
9.34 hrs.Function: 'SQLDisconnect'
Function group: 'ODBC API'
Google
Advertise here!