2013-04-10 86 views
1

我開發了一個TSP來與CTI服務器通話。在大多數情況下它的工作原理,但設置在在TSP中設置來電顯示的問題

function TSPI_lineGetCallInfo(
    hdCall : HDRVCALL; 
    lpCallInfo : LPLINECALLINFO 
) : LONG; 

主叫/被叫方ID,當我發現的偏移校正所有,但大小字段都沒有。在函數結束時,我輸出(調試器)每個字段的大小和偏移量,他們是我所期望的。但是,當我使用TAPI程序檢查這些值時,大小是不同的(但偏移量與每個調試語句完全相同),實際上大小字段5無論實際存在的是多少,而調試語句在結尾處下面的代碼顯示正確的值...

任何幫助非常感謝。

 lpCallInfo^.dwCallerIDOffset := 0; 
     lpCallInfo^.dwCallerIDSize := 0; 
     lpCallInfo^.dwCalledIDOffset := 0; 
     lpCallInfo^.dwCalledIDSize := 0; 
     lpCallInfo^.dwConnectedIDOffset := 0; 
     lpCallInfo^.dwConnectedIDSize := 0; 

     extnid := thiscall.CallItem.ExtnId; 
     phoneno := thiscall.CallItem.DialNum; 
     extnid_size := (Length(extnid) + 1) * sizeof(WCHAR); 
     phoneno_size := (Length(phoneno) + 1) * sizeof(WCHAR); 

     extnidw := StringToWideStringEx(extnid, CP_ACP); 
     phonenow := StringToWideStringEx(phoneno, CP_ACP); 

     if lpCallInfo^.dwOrigin = LINECALLORIGIN_INTERNAL then 
     begin 
     {me} 
     lpCallInfo^.dwCallerIDOffset := sizeof(TLINECALLINFO); 
     lpCallInfo^.dwCallerIDSize := extnid_size; 
     Move(ExtnIdw[1], ptr^, extnid_size * 2); 
     ptr := Pointer(integer(ptr) + lpCallInfo^.dwCallerIDSize); 
     {other party} 
     if phoneno <> '' then 
     begin 
      lpCallInfo^.dwCalledIDOffset := 
      sizeof(TLINECALLINFO) + lpCallInfo^.dwCallerIDSize; 
      lpCallInfo^.dwCalledIDSize := phoneno_size; 
      Move(phonenow[1], ptr^, phoneno_size * 2); 
     end; 
     end 
     else 
     begin 
     if thiscall.CallItem.CallType = 1 then 
     begin {incoming call} 
      {agent is the called party} 
      lpCallInfo^.dwCalledIDOffset := sizeof(TLINECALLINFO); 
      lpCallInfo^.dwCalledIDSize := extnid_size; 
      Move(ExtnIdw[1], ptr^, extnid_size); 
      ptr := Pointer(integer(ptr) + lpCallInfo^.dwCalledIDSize); 
      {other party is the caller} 
      if phoneno <> '' then 
      begin 
      lpCallInfo^.dwCallerIDOffset := 
       sizeof(TLINECALLINFO) + lpCallInfo^.dwCalledIDSize; 
      lpCallInfo^.dwCallerIDSize := phoneno_size; 
      Move(phonenow[1], ptr^, phoneno_size); 
      ptr := Pointer(integer(ptr) + lpCallInfo^.dwCallerIDSize); 
      end; 
     end 
     else 
     begin 
      {agnet is the caller} 
      lpCallInfo^.dwCallerIDOffset := sizeof(TLINECALLINFO); 
      lpCallInfo^.dwCallerIDSize := extnid_size; 
      Move(ExtnIdw[1], ptr^, extnid_size); 
      ptr := Pointer(integer(ptr) + lpCallInfo^.dwCallerIDSize); 
      {dialed number is the called party} 
      if phoneno <> '' then 
      begin 
      lpCallInfo^.dwCalledIDOffset := 
       sizeof(TLINECALLINFO) + lpCallInfo^.dwCallerIDSize; 
      lpCallInfo^.dwCalledIDSize := phoneno_size; 
      Move(phonenow[1], ptr^, phoneno_size); 
      ptr := Pointer(integer(ptr) + lpCallInfo^.dwCalledIDSize); 
      end; 
     end; 
     if (thiscall.CallItem.CallState = cs_Connected) and 
      (phoneno <> '') then 
     begin 
      lpCallInfo^.dwConnectedIDOffset := sizeof(TLINECALLINFO) + 
      lpCallInfo^.dwCallerIDSize + lpCallInfo^.dwCalledIDSize; 
      lpCallInfo^.dwConnectedIDSize := phoneno_size; 
      Move(phonenow[1], ptr^, phoneno_size); 
      ptr := Pointer(integer(ptr) + lpCallInfo^.dwConnectedIDSize); 
     end; 
     end; 
    end; 

    DEBUG('TSPI_lineGetCallInfo::dwCallerIDOffset=' + intToStr(lpCallInfo^.dwCallerIDOffset)); 
    DEBUG('TSPI_lineGetCallInfo::dwCallerIDSize=' + intToStr(lpCallInfo^.dwCallerIDSize)); 
    DEBUG('TSPI_lineGetCallInfo::dwCalledIDOffset=' + intToStr(lpCallInfo^.dwCalledIDOffset)); 
    DEBUG('TSPI_lineGetCallInfo::dwCalledIDSize=' + intToStr(lpCallInfo^.dwCalledIDSize)); 
    DEBUG('TSPI_lineGetCallInfo::dwConnectedIDOffset=' + intToStr(lpCallInfo^.dwConnectedIDOffset)); 
    DEBUG('TSPI_lineGetCallInfo::dwConnectedIDSize=' + intToStr(lpCallInfo^.dwConnectedIDSize)); 

回答

1

這些都是奇怪的結果。你的代碼似乎要結賬。它可能很長,但結果可能是由爲lpCallInfo結構保留的內存太少造成的。你使用什麼tapi程序?大多數節目預先預留大量盈餘。然而,另一個常用的方法是首先調用TSPI_lineGetCallInfo,然後在設置dwNeededSize並返回LINEERR_STRUCTURETOOSMALL之後保留確切的數量,然後向TSP「詢問」確切數量。你似乎沒有檢查dwTotalSize或設置dwNeededSize和dwUsedSize字段(這是危險的)。

請看:LINEERR constants

,讓我知道,如果它解決了問題。如果沒有,我會好奇地看到來自Tapi瀏覽器的結構日誌,但我們希望它能正常工作。祝你好運!