PocketBuilder 2.0 added the ability to send SMS messages from an application. With PocketBuilder 2.0.1, you can now receive SMS messages in PocketBuilder applications running on Windows Mobile 2003 platforms.
PocketBuilder provides a shim DLL, PKSMS20.DLL, that contains a COM object that hooks into the SMS processor. The DLL should be copied to the \Windows directory of a Pocket PC device or the \Storage\Windows directory of a Smartphone device. You must register the DLL with the operating system, then perform a soft reset on the device.
You can deploy the DLL along with registry settings in the CAB file you create for a customer application. The DLL is not part of the standard CAB file that you generate from the PocketBuilder Project painter. You can use the Enhanced CAB Generation tool to add the PKSMS20.DLL file to the CAB file, or you can add it manually.
To register the DLL, you can use the Enhanced CAB Generation tool (see “Support for SMS receiving in generated CAB files”) or either of the following approaches:
Call DLLRegisterServer from your PocketBuilder application
Modify the INI for the CAB file to add the required registry keys manually
First you register the server:
[HKEY_CLASSES_ROOT\CLSID\{CA08D891-1E24-4c69-A313-453B1120E558}\InProcServer32] @="PKSMS20.dll"
[HKEY_CLASSES_ROOT\CLSID\{CA08D891-1E24-4c69-A313-453B1120E558}]ReadOnly = dword: #
The ReadOnly value (#) can be 0 or 1. If you register the DLL by calling DLLRegisterServer, this value is automatically set to 0 (false).
When ReadOnly = dword: 0
and
you return true for an SMSSession IncomingMessage
event, PocketBuilder attempts to prevent an incoming SMS message
from displaying in the SMS inbox. PocketBuilder can fail in this
attempt when other phone-related activity interferes with
the request for nondisplay of the incoming message. In some configuations,
it is possible that the shim DLL will be prevented from operating
unless the ReadOnly attribute is set to 1.
When ReadOnly = dword: 1
,
the application will be notified of incoming SMS messages, but PocketBuilder
will not be able to delete the incoming messages from the SMS inbox
regardless of what the IncomingMessage event returns.
Next you register the inbox processor:
[HKEY_LOCAL_MACHINE\Software\Microsoft\Inbox\Svc\ SMS\Rules]{CA08D891-1E24-4c69-A313-453B1120E558} = dword:1
Unregistering a DLL
You can unregister the DLL by calling DLLUnregisterServer from
your application. You must perform a soft reset after you unregister
a DLL.
You access the Enhanced CAB Generation tool on the Tool tab of the New dialog box. The PocketBuilder Options tab page in the Enhanced CAB Generation tool has check boxes that let you include the following in a CAB file that you deploy to a device:
The SMS reception DLL, PKSMS20.DLL
The Deploy SMS Reception DLL check box is disabled by default. To enable this option, you must select the check box to include PocketBuilder support DLLs.
Registry entries for SMS reception in a PocketBuilder application
If you select the Insert Registry Entries for SMS Reception check box and generate a CAB file with the Enhanced CAB Generation tool, running the CAB file on the deployment device automatically inserts the required entries in the device registry.
A modification to the ReadOnly
string
of the SMS reception DLL registry entry
If the check box labeled SMS Reception is Read Only is selected
when you generate a CAB file with the Enhanced CAB Generation tool,
unzipping the CAB file on the deployment device automatically assigns
a ReadOnly
value of 1. This
makes PocketBuilder applications unable to delete incoming messages
from the SMS inbox.
In PocketBuilder 2.0.1, the msgmodes argument of the Open function of the SMSSession object accepts values that enable the object to receive notification of incoming messages. The syntax for the Open function remains the same as in PocketBuilder 2.0:
SMSSessionname.Open ( smsproto, msgmodes )
Valid values for the msgmodes argument are now:
In order to receive SMS messages in an application, you must set the msgmodes argument in the Open call for the SMSSession object to 2 or 3.
In PocketBuilder 2.0.1, an IncomingMessage event has been added to the SMSSession object. This event occurs when an SMSSession object that is open for receiving messages is notified of an incoming SMS message.
All instantiated SMSSession objects listening for messages are notified of an incoming SMS message. PocketBuilder can prevent the message from displaying in the SMS inbox if you set the IncomingMessage event to return true. If any SMSSession object requests deletion of the message by returning true for the IncomingMessage event, PocketBuilder will attempt to delete the message, but only after all SMSSession objects have processed the message.
Deletion of messages is dependent on registry setting
PocketBuilder applications can receive notification of an
SMS message only after you register the shim DLL, PKSMS20.DLL,
on your device. The ReadOnly registry attribute for the DLL must
be set to 0 before PocketBuilder can delete an SMS message. For
information on registering the DLL and the ReadOnly registry attribute,
see “Registering the shim DLL”.
The IncomingMessage event is synchronous with the operating system processing SMS messages. Therefore you should not include code that prompts for user input, or perform any lengthy operation in the script for this event.
The following code in the IncomingMessage event determines whether an incoming SMS message is placed in the SMS inbox or is deleted. The determination is based on whether or not the message contains the text “top secret”:
// If the message contains "top secret" it will deleted.
// Otherwise, it is placed in the inbox.
if POS(SMSMsg.text, "top secret") <> 0 then
// delete this e-mail and notify user of deletion
// in a MultiLineEdit control
mle_status.text += "~r~nWill be deleted.~r~n"
return TRUE
end if
// allow to go into the inbox
return FALSE
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |