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=457711766&fmt=text Alice Daunicht of Optimal Systems, Germany pointed out that GetVarInfo was not defined in the original code. Jeff Blalock supplied the extra code, thus : ------------------------------------------------------------------ Public Function GetVarInfo(strdata As String, lngOffset As Long, lngLength As Long) As String ' ' pluck something out of a long string ' Dim strTemp As String ' GetVarInfo = Mid(strdata, lngOffset, lngLength) ' End Function ------------------------------------------------------------------ From: "Mrshed" Subject: Re: Caller ID question Date: 22 Mar 1999 00:00:00 GMT Message-ID: <7d6cga$l3t$1@news.gte.com> References: <36F53290.86A69BF9@hknet.com> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: GTE Laboratories Incorporated Newsgroups: microsoft.public.win32.programmer.tapi,microsoft.public.win95.commtelephony Hi Francis: Here is some VB code for getting the Caller ID. The first chunk is the CallInfo Record Structure and the second is the actual function. I add the LineDevice Structure because it is the parameter for the function. 'Added the extra mem variable to hold the variable sized data returned by the 'linegetcallinfo function in the application Global Const LINECALLINFO_FIXEDSIZE = 296 Global Const LINECALLINFO_VARSIZE = 500 Global Const LINECALLINFO_TOTALSIZE = LINECALLINFO_FIXEDSIZE + LINECALLINFO_VARSIZE Type LINECALLINFO dwTotalSize As Long dwNeededSize As Long dwUsedSize As Long hLine As Long dwLineDeviceID As Long dwAddressID As Long dwBearerMode As Long dwRate As Long dwMediaMode As Long dwAppSpecific As Long dwCallID As Long dwRelatedCallID As Long dwCallParamFlags As Long dwCallStates As Long dwMonitorDigitModes As Long dwMonitorMediaModes As Long DialParams As LINEDIALPARAMS dwOrigin As Long dwReason As Long dwCompletionID As Long dwNumOwners As Long dwNumMonitors As Long dwCountryCode As Long dwTrunk As Long dwCallerIDFlags As Long dwCallerIDSize As Long dwCallerIDOffset As Long dwCallerIDNameSize As Long dwCallerIDNameOffset As Long dwCalledIDFlags As Long dwCalledIDSize As Long dwCalledIDOffset As Long dwCalledIDNameSize As Long dwCalledIDNameOffset As Long dwConnectedIDFlags As Long dwConnectedIDSize As Long dwConnectedIDOffset As Long dwConnectedIDNameSize As Long dwConnectedIDNameOffset As Long dwRedirectionIDFlags As Long dwRedirectionIDSize As Long dwRedirectionIDOffset As Long dwRedirectionIDNameSize As Long dwRedirectionIDNameOffset As Long dwRedirectingIDFlags As Long dwRedirectingIDSize As Long dwRedirectingIDOffset As Long dwRedirectingIDNameSize As Long dwRedirectingIDNameOffset As Long dwAppNameSize As Long dwAppNameOffset As Long dwDisplayableAddressSize As Long dwDisplayableAddressOffset As Long dwCalledPartySize As Long dwCalledPartyOffset As Long dwCommentSize As Long dwCommentOffset As Long dwDisplaySize As Long dwDisplayOffset As Long dwUserUserInfoSize As Long dwUserUserInfoOffset As Long dwHighLevelCompSize As Long dwHighLevelCompOffset As Long dwLowLevelCompSize As Long dwLowLevelCompOffset As Long dwChargingInfoSize As Long dwChargingInfoOffset As Long dwTerminalModesSize As Long dwTerminalModesOffset As Long dwDevSpecificSize As Long dwDevSpecificOffset As Long mem As String * LINECALLINFO_VARSIZE End Type '/////////////////////////////////////////////////////////////////////////// /////////// ' The Line_Device_Type user-defined structure collects all of the variables associated ' with a Telephone Line being used by the TAPI functions in the application. '/////////////////////////////////////////////////////////////////////////// /////////// Private Type Line_Device_Type Device_Name As String 'Device Name for a Telephone Line (Dialogic XXXX). LineID As Integer 'Device Driver ID for a Telephone Line (0,1,2 Channel #). lphLine As Long 'Device ID for a Telephone Line (XXXXXX). udtLineCall As LINECALLPARAMS 'Parameters filled in after the Line is Initialized. Reply_ID As Long 'Reply ID returned by asynchronous TAPI Functions. lhActiveCall As Long 'Handle ID to an Active Call (Out/In Bound). Line_Open As Boolean 'True: If Line is opened Line_Has_Call As Boolean 'True: If Line has a Call CallerIDAddress As String 'Caller ID Address (Phone #) received on line CallerID_Flag As Integer 'Caller ID flags received on line End Type 'Parameters: pLineDevice 'Line Device Record Structure. ' 'Return: String: Description of Call Progress State. ' Private Function TAPI_GetCallerID(pLineDevice As Line_Device_Type) As Boolean 'Local Variables. Dim RetCode As Long 'Error Code returned from the TAPI fucnctions. ' (0=Success). Dim Success As Boolean 'True: If the function executes successfully. Dim TempLineInfo As LINECALLINFO 'Structure needed to retrieve the Caller ID. Dim TempCallerID As String 'Caller ID status for the trace file. 'Initialize Local Variables. Success = True TempCallerID$ = "Unknown" 'Set the Total Size of the Caller ID Structure. TempLineInfo.dwTotalSize = LINECALLINFO_TOTALSIZE 'Retrieve the Call Information for the Inbound Line. RetCode = lineGetCallInfo(pLineDevice.lhActiveCall, TempLineInfo) If RetCode < 0 Then 'If un-successful. AddText DisplayPanel, TAPIErrMsg(RetCode) & " - Line Get Caller ID" Success = False TempCallerID$ = "Error getting Caller ID" Else 'If Successful. 'Save Caller ID Flags pLineDevice.CallerID_Flag = CInt(TempLineInfo.dwCallerIDFlags) 'Test to see that the CallerIDFlags has the bit for Caller Party ID set. If (TempLineInfo.dwCallerIDFlags And LINECALLPARTYID_ADDRESS) Then 'Test to see if the CallerID Offset and Size is greater than 0. If (TempLineInfo.dwCallerIDOffset > 0) _ And TempLineInfo.dwCallerIDSize > 0 Then 'Set the Caller ID Address found in the Memory Buffer of the Structure. pLineDevice.CallerIDAddress$ = _ GetVarInfo(TempLineInfo.mem, _ (TempLineInfo.dwCallerIDOffset - LINECALLINFO_FIXEDSIZE + 1), _ TempLineInfo.dwCallerIDSize - 1) TempCallerID$ = pLineDevice.CallerIDAddress$ Else 'If Offset or Size is not found. TempCallerID$ = "Unknown - No Offset/Size" End If Else 'If LINECALLPARTYID_ADDRESS bit is not set. TempCallerID$ = "Unknown - Flags: " & "(" & Trim$(Str$(TempLineInfo.dwCallerIDFlags)) & ")" End If 'Display results. End If AddText DisplayPanel, "Line Get Caller ID: " & TempCallerID$ 'Return Success Status. TAPI_GetCallerID = Success End Function ''''I hope this helps Francis W. L. WONG wrote in message <36F53290.86A69BF9@hknet.com>... >hi all, > >i have written some code to detect Caller ID in VB. i have the >LINE_CALLINFO event result after i've got the LINECALLSTATE_OFFERING >event. >the other parameters: >hDevice = 4332584, dwMessage = 1, dwInstance = 0, dwParam1 =32768, >dwParam2 = 0,dwParam3 =0 > >after i've called lineGetCallInfo, my result is -2147483571 and i have >all "0" in every flied of lineInfo. >I am really suffering to find out the solution. I will be very happy if >you can give me some advice. >the following is the code i've written: > >Public Sub LINECALLBACK(ByVal hDevice As Long, ByVal dwMessage As Long, >ByVal dwInstance As Long, ByVal dwParam1 As Long, ByVal dwParam2 As >Long, ByVal dwParam3 As Long) > > Dim str As String > Dim IReturn As Long > Dim lineInfo As LINECALLINFO > > If Case dwMessage = LINE_CALLINFO ' >i can have this event > If dwParam1 = LINECALLINFOSTATE_CALLERID Then > IReturn = lineGetCallInfo(hDevice, >lineInfo) ' i get -2147483571 and nothing in lineInfo > > str = "Got Caller ID" & CStr(lineInfo.dwCallerID) > End If > End If > End Sub > >thanks >francis >