Getting device phone number using extended TAPI

The phone number of the mobile device can be retrieved using the API lineGetAddressCaps. The API fills the LINEADDRESSCAPS structure that is passed in with information about the address capabilities of the given line. The member dwAddressOffset represents the offset from the start of the structure to the line address. The syntax of the function is:

LONG WINAPI lineGetAddressCaps(HLINEAPP hLineApp,DWORD dwDeviceID,DWORD dwAddressID,DWORD dwAPIVersion,DWORD dwExtVersion,LPLINEADDRESSCAPS lpAddressCaps);

You can copy the string using the code:

WCHAR* pAddress = (WCHAR*)(((BYTE*)pAddressCaps) + pAddressCaps->dwAddressOffset);

This will give you the phone number of the device. You have to check whether the dwAddressOffset member is zero or not. If it is non zero then the system found a phone number.