(Advanced) Extend PocketC API using DLLs

Postby Admin on Sun Jan 14, 2001 6:29 pm

PocketC Default APIs are designed for the general users. Overtime, specialized developers
wants additional features to be added. There was no good way to communicated with the
native APIs in PocketC 2.0. In the PocketC 3.0, I am going to introduce a way to talk
with the native APIs, and extending the default APIs with your own.

1. Optimize certain routines.
For example: If you are not satisfied with the default graphic routines provided, you
can now write your own in C++, and wrap it in a DLL. The DLL exports certain APIs that
can be called directly from PocketC applications.

2. Missing functions from the default API.
For example: you wish there is a set of API for sprite graphics, and have experience with
these code in C++. You can wrap the sprite code into a DLL, and provide a sprite engine
for the PocketC users.

Microsoft Embedded Visual C++ 3.0
Microsoft Windows NT/2000
Standard Template Library for CE
Download http://users.iol.it/g.govi/index_en.html
OrbWorks PocketC Desktop Edition Or PocketC Device Edition 3.0

I have created an example dll with project/source files to demonstrate how the DLL can be
written. You can take the example project, and expand it for your own project.

In this dll, you will find out how to export a function in C++, how to define a function
in C++, and how to get the arguments, and return value from your function.
After the funtions are defined, you will need to create a header file for PocketC compiler
to understand the set of APIs you just created in this external dll.

DemoDll.vcp -- project file
DemoDll.def -- define LoadLibrary (don't modify)
ustring.h -- string class header (don't modify)
stdafx.cpp -- debugging routines (don't modify)
stackentry.h-- argument class header (don't modify)
pktlibrary.h-- common dll headers (don't modify)

demo.Dll.cpp-- define/export functions (modify)
1. Make sure your function is in the enum
2. Make sure FUNC_DEFINE, FUNC_ASSIGN, FUNC_DECLARE are added for your function.
Read their definition if you are interested.
3. Make sure you remember to add the function export prototype for PocketC compiler to use.
syntax: #export dllname(funcid) function prototype;

To simplify the process, I bundled the extra code
into a static lib. Make sure link with this lib during the build.

This file tells the pocketc compiler that the exported functions from
the demodll. Please include this .h file if you plan to call APIs from

This test file calls the APIs we created in the dll.

Compiled test application. You should be able to compile this app file
from your device or desktop PocketC compiler.

Download http://pocketc.net/release/30/externdll.zip

contact cao@orbworks.com for questions about how to make the DLL.
Posts: 86
Joined: Fri Oct 06, 2000 6:00 am
Location: USA

Return to PocketC for CE KB

Who is online

Users browsing this forum: No registered users and 1 guest