Developers
Local Navigation
Topics within this section include:
Using __declspec(dllexport) and __declspec(dllimport)
If method_a() and method_b() are located in a .dll (exporting dll) and you want to call these methods from another dll (importing dll), do the following:
In the exporting dll, try something like:
_ _declspec(dllexport) int method_a(void){...}
_ _declspec(dllexport) void method_b(int b){...}
... and in the importing dll:
_ _declspec(dllimport) int method_a(void);
_ _declspec(dllimport) void method_b(int b);
void PagerMain(void) {
int a = method_a();
method_b(a);
}
You can also use _ _declspec(dllexport) to define a macro to make your code more readable.
How to add Address Book entries
The Address Book API allows your application to access the BlackBerry handheld's current Address Book. The following program illustrates some of the more useful capabilities of the Address Book API, including how to add your name, phone number, and email address to the Address Book.
MESSAGE msg;
int i; // counter
char buffer[30]; // buffer for display data
const NUM_FIELDS = 3; // number of fields to iterate through
//fields to iterate through
const AddressFieldType fieldType[NUM_FIELDS] = {
NAME,
EMAIL,
PHONE
};
//address handle
AddressHandle ah = NULL;
//address field handle
AddressFieldHandle afh = DB_INVALID_FIELD_HANDLE;
//information to retrieve
char *fieldname;
AddressFieldType aftype;
// returns number of Johnson AND points " ah "
// to the first address
i = get_address_match_count("Johnson", &ah);
// iterate through fields
for (i = 0; i < NUM_FIELDS; i++) {
// Gets a handle to a field in an address
afh = get_address_field_handle(ah, fieldType[i], NULL);
//Get the field's type
aftype = get_address_field_type(ah, afh);
//Get the fields name
fieldname = (char *)get_field_type_name(aftype);
//Get the fields data pointer and length
int len;
const byte* data = get_address_field_data(ah, afh, &len);
//Display information
if (data) {
RimSprintf(buffer, sizeof(buffer), " ‰s: ‰ %s", fieldname, data);
LcdPutStringXY(0,i*10 + 15,buffer,-1,0);
}
} // addressfield loop
// Wait for click
for (;;) {
RimGetMessage(&msg);
if (msg.Event == THUMB_CLICK) {
break;
}
} // thumbclick loop