Sending USSD message using TAPI

Download the source code

Unstructured Supplementary Service Data (USSD) is GSM technology used to send short message from mobile device to GSM network. It uses the signaling channel of GSM connection and can have up to 182 bytes in length. The messages received on the device are not saved. It has different set of applications and most common use of USSD message is balance enquiry. For example “*123#” used for balance enquiry in India. For a more detailed explanation of USSD messages refer to the Wikipedia.

The TAPI API lineSendUSSD is used to send the USSD command. The syntax is defined as:

LONG WINAPI lineSendUSSD(HLINE hLine,const BYTE * const lpbUSSD,DWORD dwUSSDSize,DWORD dwFlags);

The hLine parameter is the handle to the line and lpbUSSD is a pointer to USSD command. The dwUSSDSize parameter is the length of th USSD command and dwFlags flags to the USSD command which will be 0 in most cases.

The function returns a positive request identifier and is completed asynchronously. A negative integer will returned if an error occurs. The sample application presented here uses a database to store USSD commands. The application lists all the commands in the database in a list control. You can add, edit or delete the entries. Upon double clicking an entry the application sends corresponding USSD command using the Cellular Line.

9 Comments

Add yours →

  1. Hi! Thank you for your code. But I tried in my X800 with Wm 6.1 and every USSD command shows me the notification UNKNOWN APPLICATION. Do you know what is wrong?

    Joubert

  2. Hi! Thank you for your code. But I tried in my X800 with Wm 6.1 and every USSD command shows me the notification UNKNOWN APPLICATION. Do you know what is wrong?

    Joubert

  3. Hi! Thank you for your code. But I tried in my X800 with Wm 6.1 and every USSD command shows me the notification UNKNOWN APPLICATION. Do you know what is wrong?

    Joubert

  4. Hi! Thank you for your code. But I tried in my X800 with Wm 6.1 and every USSD command shows me the notification UNKNOWN APPLICATION. Do you know what is wrong?

    Joubert

  5. joubertvasc, I too got the UNKNOWN APPLICATION message when I tried some of the commands, I believe these are not exactly USSD codes. Normally USSD command start with a “*” followed by a USSD code and ends with “#”. This message is sent back when the USSD code is not recognized by the server. In this case the command is successfully sent from the device but recognized. Can you list one of the USSD you tried?

  6. joubertvasc, I too got the UNKNOWN APPLICATION message when I tried some of the commands, I believe these are not exactly USSD codes. Normally USSD command start with a “*” followed by a USSD code and ends with “#”. This message is sent back when the USSD code is not recognized by the server. In this case the command is successfully sent from the device but recognized. Can you list one of the USSD you tried?

  7. joubertvasc, I too got the UNKNOWN APPLICATION message when I tried some of the commands, I believe these are not exactly USSD codes. Normally USSD command start with a “*” followed by a USSD code and ends with “#”. This message is sent back when the USSD code is not recognized by the server. In this case the command is successfully sent from the device but recognized. Can you list one of the USSD you tried?

  8. joubertvasc, I too got the UNKNOWN APPLICATION message when I tried some of the commands, I believe these are not exactly USSD codes. Normally USSD command start with a “*” followed by a USSD code and ends with “#”. This message is sent back when the USSD code is not recognized by the server. In this case the command is successfully sent from the device but recognized. Can you list one of the USSD you tried?

Leave a Reply