1

我开发了一个 TSP 来与 CTI 服务器通信。在大多数情况下,它可以工作,但是在设置呼叫者/被叫 ID 方时,在

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

我发现偏移量都是正确的,但大小字段不是。在函数结束时,我输出(到调试器)每个字段的大小和偏移量,它们是我所期望的。但是当我使用 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));
4

1 回答 1

1

这些都是奇怪的结果。您的代码似乎已签出。这可能是一个远景,但结果可能是由于为 lpCallInfo 结构保留的内存太少造成的。你用什么tapi程序?大多数程序只是预先保留大量盈余。但是,另一种常用的方法是通过首先调用 TSPI_lineGetCallInfo 并在设置 dwNeededSize 并返回 LINEERR_STRUCTURETOOSMALL 后保留确切的数量来“询问”TSP 所需的确切数量。您似乎没有检查 dwTotalSize 或设置 dwNeededSize 和 dwUsedSize 字段(这很危险)。

请看:LINEERR 常量

并让我知道它是否解决了问题。如果没有,我会很好奇从 Tapi 浏览器中查看结构日志,但我们希望它能正常工作。祝你好运!

于 2013-04-10T14:19:07.410 回答