Suppose you have created a C dynamic library, SIMPLE.DLL, that contains a function called SimpleFunc that accepts two parameters: a character string and a structure. The following statement declares the function in PocketBuilder, passing the arguments by reference:
FUNCTION int SimpleFunc(REF string lastname, &
REF my_str pbstr) LIBRARY "simple.dll"
The Windows CE API includes a subset of the functions in the Windows API. The Windows CE API libraries have different names. The following examples show sample declarations for functions in the Windows CE library coredll.dll.
On the desktop, these functions are in the Windows library user32.dll. To test the function call on the desktop, substitute the desktop equivalent, shown in comment lines after each call, for the Windows CE version.
FUNCTION ulong CreateWindowEx( ulong dwExStyle, & readonly string ClassName, & readonly string WindowName, & long dwStyle, & long xPos, long yPos, long wwidth, long wheight, & ulong hwndParent, ulong hMenu, ulong hInstance, & ulong lParams ) & library "Coredll.dll" alias for "CreateWindowExW"
// library "user32.dll" alias for "CreateWindowExW" FUNCTION ulong BringWindowToTop( ulong hwnd ) & library "Coredll.dll"
//FUNCTION ulong BringWindowToTop( ulong hwnd ) & // library "user32.dll" FUNCTION ulong SendMessageStr( ulong hwnd, & ulong wMsg, ulong wParam, & readonly string lParam ) & library "Coredll.dll" alias for "SendMessageW" // library "user32.dll" alias for "SendMessageW" FUNCTION ulong SendMessageLong( ulong hwnd, & ulong wMsg, ulong wParam, & ulong lParam ) & library "Coredll.dll" alias for "SendMessageW" // library "user32.dll" alias for "SendMessageW" FUNCTION ulong SendMessagePtr( ulong hwnd, & ulong wMsg, ulong wParam, & REF ulong lParam[] ) & library "Coredll.dll" alias for "SendMessageW" // library "user32.dll" alias for "SendMessageW" FUNCTION ulong SetWindowPos( ulong hwnd, ulong hwndAfter, & ulong xPos, ulong yPos, ulong cX, ulong cY, & ulong wFlage ) & library "Coredll.dll" // library "user32.dll"
The following statement declares the function that registers common controls classes from the common control dynamic-link library commctrl.dll on Windows CE:
FUNCTION ulong InitCommonControlsEx ( ulong & pInitCtrls[] )library "commctrl.dll” // WinCE
This is the equivalent statement on the desktop:
FUNCTION ulong InitCommonControlsEx( REF ulong & pInitCtrls[2] ) library "comctl32.dll" // Win32
For a partial example that uses some of these declarations, see “Using external functions in a script”.
You can find a sample application that uses Windows CE API functions in the PocketBuilder project on the Sybase CodeXchange Web site.
For more information about coredll.dll, commctrl.dll, and other modules, see the section on Windows CE modules in the Microsoft Windows CE 3.0 API documentation.
The following statement declares the function that loads and initializes the Microsoft RichInk edit control:
FUNCTION ulong InitInkX_CE() & library "inkx.dll" alias for "InitInkX"
For more information about using the RichInk edit control, see “Using Rich Ink Technology in Microsoft Windows CE 3.0” in the MSDN library.
Remote API (RAPI) is a set of application programming interfaces that let applications running on the desktop invoke functions directly on the Windows CE based device. The set of functions is similar to the Windows CE API, with functions for managing the registry, file system, and databases, and for querying the system configuration. There are additional functions for initializing the RAPI subsystem and enhancing performance.The following example shows declarations of the CeCloseHandle and CeCreateFile RAPI functions:
Function Boolean CeCloseHandle ( Long hObject) Library "rapi.dll"
Function Long CeCreateFile ( & String lpFileName, & uLong dwDesiredAccess, & uLong dwShareMode, & REF SECURITY_ATTRIBUTES lpSecurityAttributes, & Long dwCreationDistribution, & Long dwFlagsAndAttributes, & Long hTemplateFile) Library "rapi.dll"
For more information about RAPI, see the MSDN library.
For a sample using RAPI, see the Sybase CodeXchange Web site.