|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
POWERBUILDER LINKS YOU MUST CLICK ON Tutorial Adding Caller ID to Your PowerBuilder Applications
A how-to
By: Deanne M. Chance
Nov. 11, 2006 12:00 PM
How did I know the values of the hexadecimal constants to begin with? There are many sources but one I find useful is a tool called ApiViewer. It's invaluable when it comes to prototyping Win32 API calls. A link to it can be found at the bottom in the references section. A further look at the prototype for CreateFile sheds some light onto the other constants, in particular 3, 0, 3. Again, if we look at the prototype for CreateFile, we see that these represent the ShareMode, SecurityAttributes, and CreateDisposition, respectively. For the ShareMode we are interested in FILE_SHARE_READ | FILE_SHARE_WRITE. Again, look at APIViewer to find out their hex values, or them together and convert to yield decimal 3. For the SecurityAttributes, this represents a pointer to a SECURITY_ATTRIBUTES structure that determines whether or not the returned handle can be inherited by child processes. If lpSecurityAttributes is NULL, the handle cannot be inherited. This is what is desired in our case, thus the zero. Finally, a word about the CreateDisposition, which is an action to take on files that do and do not exist. With respect to a comport, we expect it to exist. Therefore, the value OPEN_EXISTING is in order. Again, use the ApiViewer tool to see the numeric values of this constant. Back to our project, the next order of business is to set the modem up to capture caller-ID information. The command for doing this may vary depending on your manufacture; consult your modem documentation. I was using a Toshiba software modem. With respect to the call to WriteFile, ls_write is the text to send to the modem, ll_write is the length of the text sent to the modem, and ll_written is the length actually written to the modem.
//turn on caller-ID Now all we have to do is wait for an incoming phone call and pick off the data. A couple of points are important here. One, the string that indicates the information is the phone number can vary depending on your particular modem. Again, experiment or consult your modem documentation. The second thing is that the data is returned with carriage returns and line feeds. While nice to look at, it can make parsing more difficult. Therefore, I've replaced them with spaces. With respect to the call to ReadFile, it follows the same logic as WriteFile(see above). Here is what the function to pick off the caller id looks like:
String ls_read Finally, in the close event we will need to make sure we close the open comm port.
CloseHandle(il_hCon) That's it! Incredibly simple but powerful coupled with a
database of phone numbers you can query to personalize your
applications for your end users.
Resources http://electronics.howstuffworks.com/question409.htm http://cdgenp01.csd.toshiba.com/content/support/downloads/v_92_manual_20020815.pdf PBDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING POWERBUILDER / SYBASE NEWS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||