VB调用的动态库是
Declare Sub GetKHTState Lib "mtudll.DLL" (ByVal port As Long, ByRef state As Integer)
现在我要把此调用的动态库换成DELPHI的,不知道如何处理。
以下是VB代码,state定义的是as integer,port as integer
        GetKHTState port, state
        If state And &HF Then
            'Text3 = Right(Text3, 200) & "port" & port & "=" & Hex(state) & vbCrLf
            
            Text3 = Right(Text3, 500) & " port=" & port _
                    & "->来电=" & IIf(state And &H1, "1", "0") _
                    & " 振铃=" & IIf(state And &H2, "1", "0") _
                    & " 错误=" & IIf(state And &H4, "1", "0") _
                    & " dtmf=" & IIf(state And &H8, "1", "0") _
                    & " Dtmf=" & ((state And &HF0) / 16) & vbCrLf _
                    & "------------------" & vbCrLf
        End If
我要把他换成DELPHI,不知道如何处理,分不够再加。谢谢了,待急。

解决方案 »

  1.   

    定义:
    procedure GetKHTState(port: Cardinal; state: integer); stdcall; external mtudll name 'GetKHTState';代码:
    GetKHTState(port, state);
    If state And &HF > 0 Then
    begin
    Text3 := Right(Text3, 500) + ' port=' + IntToStr(port) +
    '->来电=';
    If state And &H1 > 0 Then
    Text3:=Text3+'1'
    else
    Text3:=Text3+'0'; 
    Text3:=Text3+' 振铃=';
    If state And &H2 > 0 Then
    Text3:=Text3+'1'
    else
    Text3:=Text3+'0';
    Text3:=Text3+' 错误=';
    If state And &H4 > 0 Then
    Text3:=Text3+'1'
    else
    Text3:=Text3+'0';
    Text3:=Text3+' dtmf=';
    If state And &H8 > 0 Then
    Text3:=Text3+'1'
    else
    Text3:=Text3+'0';
    Text3:=Text3+' Dtmf=' + IntToStr((state And &HF0) / 16) + #13#10
    + '------------------' + #13#10;
    End;//这里Text3是当作字符串来操作的,如果是控件,你需要用Text3.Text或Text3.Caption来进行操作
      

  2.   

    VB ByRef state 这个是地址的意思,
    delphi定义成state: integer,一下就报错了,
      

  3.   

    但是DELPHI 没有If state And &H1 > 0 Then这样的语句啊,没有&H1
      

  4.   

    把代码里面的&H全部换成$试试
      

  5.   

    IIf(state And &H1, "1", "0")
    state and $1
    这样肯定也会报错的啊。