Repost Windows ce api rapi

Source: Internet
Author: User

1. rapi Overview
After rapi is available in Windows CE, PC applicationsProgramYou can remotely manage Windows CE devices. The export function processes the file system, registry, and database, and the functions used to query system configurations. Most rapis are copies of Windows ce api functions, and only a few functions extend the API.

Rapi functions are listed in Windows ce api reference, but there will be PC applications called instead of widows CE applications. Each function name has a prefix ce to distinguish it from its copy of window ce. For example, the function getstoreinformation in Windows CE is called cegetstoreinformation in the rapi version of this function. In Windows CE applications, rapi functions are not called.

2. initialize rapi
Before calling the rapi function, you must call the cerapiinit or cerapiinitex function to initialize the rapi library. The difference between these two functions is that cerapiinit will be blocked (waiting for a successful connection with the Windows CE device), and cerapiinitex will not wait for the connection to succeed.

The prototype of these two functions.

Hresult cerapiini (void );

Hresult cerapiinitex (rapiinit * prapiinit );

Typedef struct _ rapiinit

{

DWORD cbsize;

Handle herapiinit;

Stdapi hrrapiinit;

} Rapiinit;

Before calling cerapiinitex, you must enter the cbsize field.

3. End the rapi session
Call the following function to clear all necessary rapi calls:

Hresult cerapiuninit (void );

This function disables rapi communication with remote devices. If the rapi session is not initialized

Cerapiuninit will return e_fail

4. predefined rapi Functions
The rapi service includes many predefined rapi functions. During connection, the PC end copies Windows CE functions. Therefore, just as getstoreinformation will make the object storage cry and return space to the Windows CE program, cegetstoreinformation will return the same information about the connected Windows CE device to the PC-based application.

4.1 rapi system information functions

Most functions are copies of Windows CE functions, except cegetpassword and cerapiinvoke

System information functions

Function

Description

Cegetsysteminfo
Returns information about the current system.

Cegetsystemmetrics
Obtain the size and system settings of Windows Elements

Cegetversionex
Obtain the extension information of the currently running operating system version.

Cegetsystempowerstatusex
Obtain Battery status

Ceglobalmemorystatus
Obtain system physical memory and virtual memory information

Cegetstoreinformation
Obtain the storage Information and enter the store_information structure.

4.2 rapi file and directory management functions

The following list shows the rapi file management functions. This list shows that almost all file functions that can be used for Windows CE applications can be used for PC-based programs.

Function

Description

Cecopyfile
Copy a file

Cecreatedirectory
Create directory

Cecreatefile
Create, open files, pipelines, communication resources, disk devices, or the console. Returns a handle to access the object.

Cedeletefile
Delete an object

Cefindallfiles
Obtains information about all files and directories from the specified Windows CE directory and copies it to an array containing the ce_find_data structure.

Cefindfirstfile
Search for a file matching the given file name in the directory

Cefindclose
Closes the specified search handle. The cefindfirstfile and cefindnextfile functions use this handle to search for files.

Cefindnextfile
Continue searching for files from the last accessed cefindfirstfile

Cegetfileattributes
Returns the attributes of a specified file or directory.

Cegetfilesize
Obtains the size of the specified object in bytes.

Cegetfiletime
Obtain the file creation date, last access date, and last modification date.

Cemovefile
Move (rename) a file or directory

Cereadfile
Read File data from file pointer

Cewritefile
Write File data from the file pointer

The table contains a new function cefindallfiles, which is unavailable to Windows CE applications.

Prototype:

Bool cefindallfiles (lpcwstr szpath, DWORD dwflags,

Lpdword lpdwfoundcount,

Lplpce_find_data ppfinddataarray );

Cefindallfiles is designed to enhance performance. You only need to call it once to return all the files in the given directory, instead of repeating rapi calls using cefindfirstfile and cefindnextfile.

For more information about the parameters, see SDK...

4.3 rapi database functions

The following list shows the rapi database functions. These functions simulate the extended database APIs found in Windows CE.

Database functions

Cecreatedatabase
Ceopendatabaseex

Cecreatedatabaseex
Cereadrecordprops

Cedeletedatabase
Cereadrecordpro1_x

Cedeletedatabaseex
Ceseekdatabase

Cedeleterecord
Cesetdatabaseinfo

Cefindfirstdatabase
Cesetdatabaseinfoex

Cefindfirstdatabaseex
Cewriterecordprops

Cefindnextdatabase
Cemountdbvol

Cefindnextdatabaseex
Ceunmountdbvol

Ceoidgetinfo
Ceenumdbvolumes

Ceoidgetinfoex
Cefindalldatabases

Ceopendatabase

Almost all database functions have copies of Windows CE. The only exception is the new function cecreatedatabase.

Like cefindallfiles, this function is designed to enhance performance.

Function prototype:

Bool cefindalldatabases (DWORD dwdbasetype, word wflags,

Lpword cfinddata,

Lplpcedb_find_data ppfinddata );

For more information about the parameters, see SDK...

Rapi Registry management functions

These functions work the same way as their Windows CE counterparts, but remember that all strings are in unicode format.

4.4 Other API functions

It can be said that functions on Windows CE can be implemented through rapi. I cannot list them here.

Power display function

Stdapi _ (bool) cegetsystempowerstatusex

(

Psystem_power_status_ex pstatus,

Bool fupdate

);

To create a process, you can open the application on ce.

Cecreateprocess

Form management functions

Form management functions

Cegetwindow
Cegetwindowtext

Cegetwindowlong
Cegetclassname

5. pget example Program
Rapi. h and rapi. Lib must be added to rapi applications.

The setting method in evc4.0 is as follows:

[Tools] \ [OPTIONS…] \ [Directories] to set their directories.

The setting method in vss2005 is as follows:

[Tools] \ [Options] \ [projects and solutions] [VC ++ directories]

The directory where the. h file Lib is stored.

C: \ Program Files \ Windows CE tools \ wce420 \ Pocket PC 2003 \ ActiveSync \ Inc

C: \ Program Files \ Windows CE tools \ wce420 \ Pocket PC 2003 \ ActiveSync \ Lib

C: \ Program Files \ Windows CE tools \ wce500 \ Windows Mobile 5.0 Pocket pc sdk \ ActiveSync \ Inc

C: \ Program Files \ Windows CE tools \ wce500 \ Windows Mobile 5.0 Pocket pc sdk \ ActiveSync \ Lib

This is an SDK example.Code

Path

Ppc2003 and wm5 PPC

C: \ Program Files \ Windows CE tools \ wce420 \ Pocket PC 2003 \ samples \ Win32 \ rapi \ pget

C: \ Program Files \ Windows CE tools \ wce500 \ Windows Mobile 5.0 Pocket pc sdk \ samples \ CPP \ Win32 \ rapi \ pget

Wm5 sp

C: \ Program Files \ Windows CE tools \ wce500 \ Windows Mobile 5.0 smartphone SDK \ samples \ CPP \ Win32 \ rapi \ pget

This program is a console application that Copies files from a small machine to a PC.

The Code section is not specific. Just describe the process

The command for copying files is;

Pget <ce Source File> <PC target File>

1. Use cerapiinit () for initialization.

2. cefindfirstfile () to determine whether the file exists on the CE end.

3. cecreatefile () to open the CE-side file.

4. createfile () is used to create the file copied to the PC end.

5. cereadfile () reads ce files into the cache.

6. writefile () saves the data in the cache area to the PC end.

7. ceclosehandle () and closehandle () close the file handle on ce and PC.

8. Call cerapiuninit.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.