| |

VerySource

 Forgot password?
 Register
Search
View: 9|Reply: 1

Problems calling DLLs written in C

[Copy link]

1

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 China

Post time: 2020-3-14 09:30:01
| Show all posts |Read mode
'typedef struct _state_now {
'unsigned char ifTel: 1;
'unsigned char ifRing: 1;
'unsigned char ifError: 1;
'unsigned char ifDtmf: 1;
'unsigned char dtmf: 4;
'unsigned char hd;
'} STATE_NOW;

'Function: query status
'Entry: 1 port, port number (0-7 corresponds to 64-71 of USB port), state
'Exit: 1 succeeded; 0 failed.
'int WINAPI GetKHTState (int port, STATE_NOW * state)

Others wrote in VB
Declare Sub GetKHTState Lib "mtudll.DLL" (ByVal port As Long, ByRef state As Integer)


The code I call with DELPHI is as follows
 type
  STATE_NOW = packed record
    ifTel: char;
    ifRing: char;
    ifError: char;
    ifDtmf: char;
    dtmf: array [1..4] of char;
    hd: pchar;
  end;
  PSTATE_NOW = ^ STATE_NOW;

function GetKHTState (port: integer; state: PSTATE_NOW): integer; stdcall; external 'mtudll.DLL' name 'GetKHTState';

Var
st: pSTATE_NOW;
begin
if GetKHTState (64, st) = 1 then // true when executed here, indicating successful return
   edit1.Text: = st.ifTel // but did not get any data, it is empty

I was wrong there, what should I do?
Very anxious, help?
Reply

Use magic Report

0

Threads

9

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: 2020-6-10 22:00:01
| Show all posts
Var
st:pSTATE_NOW;
begin
new( st );
if GetKHTState(64,st)=1 then //true when executed here, indicating successful return
edit1.Text :=st.ifTel //But no data is obtained, it is empty
dispose( st );
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list