How DesktopRAPIInvoker Launches The HTML Viewer On The CE Device
Creating the DLL for the Remotely Invoked Function
As mentioned in this lesson's introduction, there are two keys to creating a CE function that may be remotely invoked. First, the function prototype must conform exactly to the declaration you see below:
HRESULT (STDAPICALLTYPE RAPIEXT) MyRapiInvokableFxn ( DWORD cbInput, // [IN] BYTE *pInput, // [IN] DWORD *pcbOutput, // [OUT] BYTE **ppOutput, // [OUT] IRAPIStream *pIRAPIStream // [IN] );
Second, you must make sure the name exported for the function is a C-style function name, not a C++-style "decorated" name. C++ compilers generate arbitrary function names that encode things such as parameter list information, function return types, and class membership. These names are not standardized, so you can't safely use them to invoke functions in the DLL you are constructing for use with RAPI. This can be a bit of a drawback if you enjoy the convenience of some C++ development environment tools.
Figure 1: Looking At DLL Exports With The Dependency Walker
This is the Dependency Walker's view of the DLL that contains LaunchViewer(), the function you invoke from DesktopRAPIInvoker. The DLL was built using files generated by App Wizard. When the files were initially created, I chose the option that includes an exported dummy variable and an exported dummy function in the generated files. Notice that there are three more or less "English" looking names in the Exports pane: LaunchViewer, the exported function, and fnDRICompanion and nDRICompanion, the automatically generated "dummy" exports. By contrast, there are two long (ugly) names above, which happen to be the class contructor and destructor for CDRICompanion. If a function you are trying to call from CeRapiInvoke() looks something like the first two names in the Exports pane, you've gotten C++ style function naming and the call won't be resolved.
Summing Up & Looking Ahead
Getting you DLL properly declared and built is without question the most challenging part of multi-platform CE programming. In this lesson, you've seen how a remotely invoked function must be declared. In the next, you'll dissect the header file for the DLL that packages your remote function. Given these basics, you'll have a powerful tool for creating customized, collaborative presentation applications on the CE device.
About the Author
Nancy Nicolaisen is a software engineer who has designed and implemented highly modular Windows CE products that include features such as full remote diagnostics, CE-side data compression, dynamically constructed user interface, automatic screen size detection, and entry time data validation.
In addition to writing for Developer.com, she has written several books, including Making Win 32 Applications Mobile.
Page 2 of 2