March 21, 2019
Hot Topics:

How DesktopRAPIInvoker Launches The HTML Viewer On The CE Device

  • January 28, 2005
  • By Nancy Nicolaisen
  • Send Email »
  • More Articles »

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:

                   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.

If you use Visual C++ Wizards or other similar productivity facilities to generate the skeleton files for your DLL, a thicket of macros and defines are automatically invoked in your behalf. These make it hard to tell just what kind of function names you'll end up with. To see exactly what is exported by the DLL, use the Visual C++ Dependency Walker to look at the exported symbols in the DLL.

Click here for a larger image.

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

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date