This accompanies my Caller ID FAQ at http://www.ainslie.org.uk/callerid.htm The following code example was posted to the TAPI newsgroup but has not been tested! It may also be found at http://www.deja.com/getdoc.xp?AN=398786842&fmt=text From: "rj@adphone.co.nz" Subject: Re: retrieving caller's telephone number Date: 08 Oct 1998 00:00:00 GMT Message-ID: <6vgojo$r5o$1@news.wave.co.nz> References: <361b3931.187097@news.jaring.my> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: Wave Internet Services Newsgroups: microsoft.public.win32.programmer.tapi Here's some code, Hope it helps void CTapiLine::GetCallInfo() { LPLINECALLINFO lpCallInfo = NULL; m_CallerID.Empty(); if (!m_hCall) return; lpCallInfo = I_lineGetCallInfo(lpCallInfo, m_hCall); // just a wrapper with some memory allocation stuff. if (!lpCallInfo) { DebugLog("ERROR CallerID call info unsucessfull"); return; }; switch(lpCallInfo->dwCallerIDFlags) { case LINECALLPARTYID_ADDRESS: m_CallerID = (char*)lpCallInfo->dwCallerIDOffset; DebugLog(m_CallerID); break; case LINECALLPARTYID_BLOCKED: DebugLog("CALLERID LINECALLPARTYID_BLOCKED Caller ID information for the call has been blocked by the caller but would otherwise have been available."); break; case LINECALLPARTYID_OUTOFAREA: DebugLog("CALLERID LINECALLPARTYID_OUTOFAREA Caller ID information for the call is not available since it is not propagated all the way by the network."); break; case LINECALLPARTYID_NAME: DebugLog("CALLERID LINECALLPARTYID_NAME The caller ID information for the call is the caller's name (from a table maintained inside the switch). It is provided in the caller ID name variably sized field."); break; case LINECALLPARTYID_PARTIAL: DebugLog("CALLERID LINECALLPARTYID_PARTIAL Caller ID information for the call is valid but is limited to partial number information."); break; case LINECALLPARTYID_UNKNOWN: DebugLog("CALLERID LINECALLPARTYID_UNKNOWN Caller ID information is currently unknown but it may become known later."); break; case LINECALLPARTYID_UNAVAIL: DebugLog("CALLERID LINECALLPARTYID_UNAVAIL Caller ID information is unavailable and will not become known later."); break; default: DebugLog("CALLERID DEFAULT unknown caller ID flag"); }; LocalFree(lpCallInfo); }; LPLINECALLINFO CTapiLine::I_lineGetCallInfo( LPLINECALLINFO lpLineCallInfo, HCALL hCall) { size_t sizeofLineCallInfo = sizeof(LINECALLINFO) + 1024; long lReturn; // Continue this loop until the structure is big enough. while(TRUE) { // Make sure the buffer exists, is valid and big enough. lpLineCallInfo = (LPLINECALLINFO) CheckAndReAllocBuffer( (LPVOID) lpLineCallInfo, sizeofLineCallInfo, "lineGetCallInfo"); if (lpLineCallInfo == NULL) return NULL; // Make the call to fill the structure. do { lReturn = lineGetCallInfo(hCall, lpLineCallInfo); if (HandleLineErr(lReturn)) continue; else { DebugError("lineGetCallInfo unhandled error: "); DebugError(GetErrorText(lReturn)); LocalFree(lpLineCallInfo); return NULL; } } while (lReturn != SUCCESS); // If the buffer was big enough, then succeed. if ((lpLineCallInfo->dwNeededSize) <= (lpLineCallInfo->dwTotalSize)) { return lpLineCallInfo; } // Buffer wasn't big enough. Make it bigger and try again. sizeofLineCallInfo = lpLineCallInfo->dwNeededSize; } }