[Previous] [TOC]

Extending Visual Basic Using COM DLLs


The Windows CE toolkit does not allow you to declare API functions, but you can use the CreateObject function to create instances of ActiveX components. Therefore, if you want to use any of the Windows CE API functions, you will need to create an ActiveX object that wraps the functionality required. Before embarking on this task, I would advise that you check the necessity for the particular API functions you want to use. Remember that the operating system itself contains only a subset of the Win32 API. Whereas the Win32 API has some 15,000 functions, the Windows CE API has only around 1200-the function you require might not even exist. I can recommend the book Microsoft Windows CE Programmer's Guide (Microsoft Press) as an excellent reference. This book gives complete documentation of the Windows CE API and covers topics such as communications and file and Registry access.

There are two "legitimate" areas of functionality for which you might decide to write ActiveX components. The first is the ActiveSync functionality. The Windows CE databases can be synchronized with a PC using ActiveSync. When your HPC performs its synchronization, what it is actually synchronizing are the databases on your device. The HPC is shipped with the Contacts, Calendar, Inbox, and other databases. In addition, you can create your own databases using the HPC Database application that comes with most HPC devices. The HPC Database application is normally found in the Databases icon on the desktop. You can configure ActiveSync to maintain synchronized copies of any or all these databases. Using the API you can achieve this functionality in code, which is useful if you write applications incorporating the Windows CE database functionality.

The database API functions are another area for which you might want to write wrappers. The API gives you the ability to create, open, enumerate, read, write, and delete the Windows CE database files.

To create an ActiveX wrapper you will need Visual C++ 5 and the Windows CE Toolkit for Visual C++ 5. Using this combination you can create a DLL that implements an Active Template Library (ATL) COM object, and then create instances of that object in your Visual Basic program by using the CreateObject function.

[Previous] [TOC]