C
cyfflying
Unregistered / Unconfirmed
GUEST, unregistred user!
我调用东软的DLL,出现了问题
C中的函数原型
int cmpp_recv(conn_desc *conn,cmppe_packet *cp, unsigned char is_break,unsigned int *seq);
conn_desc结构如下
struct conn_desc{
SOCKET sock;
unsigned long seq;
int status;
char act_flag;
};
cmppe_packet结构如下
struct cmppe_packet{
cmppe_head pk_head;
signed int result;
union{
0 pk_deliver;
1 pk_login_resp;
2 pk_submit_resp;
}pk_data;
};
cmppe_head结构如下
struct cmppe_head{
unsigned int pk_len;
unsigned int pk_cmd;
unsigned int pk_stat;
unsigned int pk_seq;
};
东软自带的DEMO中调用代码如下
main()
{
conn_desc conn;
cmppe_packet cp;
memset(&conn,0,sizeof(conn));
memset(&cp,0,sizeof(cmppe_packet));
stat = cmpp_recv(&conn,&cp,0);
}
小弟定义的代码如下
type
Tconn = packed record
sock:TSocket;
seq:longint;
status:integer;
act_flagchar;
end;
Tcmpp_packet=packed record
head:Tcmpp_head;
result:longword;
case integer of
0pk_delive:byte);
1pk_login:byte);
2pk_submit_resp:byte);
end;
Tcmpp_head=packed record
pk_len:longword;
pk_cmd:longword;
pk_stat:longword;
pk_seq:longword;
end;
function cmpp_recv(connointer;Tcmpp_packetointer;is_break:byte):integer;Cdecl;
implementation
function cmpp_recv;external 'api.dll' name 'cmpp_recv';
end.
调用的代码如下
var
login:^Tlogin;
head:^Tcmpp_packet;
begin
getMem(conn,sizeof(Tconn));
ZeroMemory(conn,sizeof(Tconn));
getMem(head,sizeof(Tcmpp_packet));
ZeroMemory(head,sizeof(Tcmpp_packet));
cmpp_recv(conn,head,0);
end;
运行后报内存错误,小弟对C实在是生疏,请各位大侠指点
C中的函数原型
int cmpp_recv(conn_desc *conn,cmppe_packet *cp, unsigned char is_break,unsigned int *seq);
conn_desc结构如下
struct conn_desc{
SOCKET sock;
unsigned long seq;
int status;
char act_flag;
};
cmppe_packet结构如下
struct cmppe_packet{
cmppe_head pk_head;
signed int result;
union{
0 pk_deliver;
1 pk_login_resp;
2 pk_submit_resp;
}pk_data;
};
cmppe_head结构如下
struct cmppe_head{
unsigned int pk_len;
unsigned int pk_cmd;
unsigned int pk_stat;
unsigned int pk_seq;
};
东软自带的DEMO中调用代码如下
main()
{
conn_desc conn;
cmppe_packet cp;
memset(&conn,0,sizeof(conn));
memset(&cp,0,sizeof(cmppe_packet));
stat = cmpp_recv(&conn,&cp,0);
}
小弟定义的代码如下
type
Tconn = packed record
sock:TSocket;
seq:longint;
status:integer;
act_flagchar;
end;
Tcmpp_packet=packed record
head:Tcmpp_head;
result:longword;
case integer of
0pk_delive:byte);
1pk_login:byte);
2pk_submit_resp:byte);
end;
Tcmpp_head=packed record
pk_len:longword;
pk_cmd:longword;
pk_stat:longword;
pk_seq:longword;
end;
function cmpp_recv(connointer;Tcmpp_packetointer;is_break:byte):integer;Cdecl;
implementation
function cmpp_recv;external 'api.dll' name 'cmpp_recv';
end.
调用的代码如下
var
login:^Tlogin;
head:^Tcmpp_packet;
begin
getMem(conn,sizeof(Tconn));
ZeroMemory(conn,sizeof(Tconn));
getMem(head,sizeof(Tcmpp_packet));
ZeroMemory(head,sizeof(Tcmpp_packet));
cmpp_recv(conn,head,0);
end;
运行后报内存错误,小弟对C实在是生疏,请各位大侠指点