请教delphi调用带指针的结构体问题(50)

  • 主题发起人 主题发起人 常广荣
  • 开始时间 开始时间

常广荣

Unregistered / Unconfirmed
GUEST, unregistred user!
请教delphi调用带指针的结构体问题vc版本//打开前端通道typedef struct tagDVSNET_CHANNEL_INFO { unsigned long lStructSize; //结构大小,设置为sizeof(DVSNET_CHANNEL_INFO) unsigned long dwStreamNo; //码流号(用于双码流) unsigned long nProtocol; //网络协议//数据发送协议#define PROTOCOL_TCP 0 //TCP协议#define PROTOCOL_UDP 1 //UDP协议#define PROTOCOL_MULTICAST 2 //组播协议 HWND hWndDisplay; //显示窗口 unsigned long bPlayStart; //是否显示 0-不显示 1-显示 unsigned long dwBackFrameCount; //缓冲帧数 unsigned long dwReserved; //保留}DVSNET_CHANNEL_INFO;DVSNET_API int __stdcall DVSNET_OpenChannel(HANDLE hServer,unsigned long nChannel,DVSNET_CHANNEL_INFO *pChannelInfo,HANDLE *phChannel);我转成delphi//打开前端通道type DVSNET_CHANNEL_INFO = ^tagDVSNET_CHANNEL_INFO; tagDVSNET_CHANNEL_INFO = packed record lStructSize: dword; //结构大小,设置为sizeof(DVSNET_CHANNEL_INFO) dwStreamNo: dword; //码流号(用于双码流) nProtocol: dword; //网络协议//数据发送协议 PROTOCOL_TCP: integer; //TCP协议 0 PROTOCOL_UDP: integer; //UDP协议 1 PROTOCOL_MULTICAST: integer; //组播协议 2 hWndDisplay: hwnd; //显示窗口 bPlayStart: dword; //是否显示 0-不显示 1-显示 dwBackFrameCount: dword; //缓冲帧数 dwReserved: dword; //保留 end;function DVSNET_OpenChannel(hServer: THandle; nChannel: Dword; pChannelInfo: DVSNET_CHANNEL_INFO; phChannel: PHandle): Integer; stdcall;在窗口中应用procedure TFrmdvsnetclient.RzBitBtn3Click(Sender: TObject);var ChannelInfo: DVSNET_CHANNEL_INFO; hWndf: hwnd;begin//----打开通道 New(ChannelInfo); ChannelInfo.PROTOCOL_TCP := 0; ChannelInfo.PROTOCOL_UDP := 1; ChannelInfo.PROTOCOL_MULTICAST := 2; DVSNET_OpenChannel(Serverwnp, 0, @ChannelInfo, @Channelwnp); showmessage(inttostr(DVSNET_OpenChannel(Serverwnp, 0, @ChannelInfo, @Channelwnp))); end;返回的结果是错误的,提示非法的参数,哪位大哥帮看看呢
 
定义数据类型tagDVSNET_CHANNEL_INFO出错了.VC 那里7个,delphi那里有10个.
 
vc里还包括常量呢
 
那个是宏,不是常量.你在vc里sizeoftypedef struct tagDVSNET_CHANNEL_INFO { unsigned long lStructSize; //½á¹¹´óС£¬ÉèÖÃΪsizeof(DVSNET_CHANNEL_INFO) unsigned long dwStreamNo; //ÂëÁ÷ºÅ(ÓÃÓÚË«ÂëÁ÷) unsigned long nProtocol; //ÍøÂçЭÒé//Êý¾Ý·¢ËÍЭÒé#define PROTOCOL_TCP 0 //TCPЭÒé#define PROTOCOL_UDP 1 //UDPЭÒé#define PROTOCOL_MULTICAST 2 //×鲥ЭÒé HWND hWndDisplay; //ÏÔʾ´°¿Ú unsigned long bPlayStart; //ÊÇ·ñÏÔʾ 0-²»ÏÔʾ 1-ÏÔʾ unsigned long dwBackFrameCount; //»º³åÖ¡Êý unsigned long dwReserved; //±£Áô}DVSNET_CHANNEL_INFO;和typedef struct tagDVSNET_CHANNEL_INFO { unsigned long lStructSize; //½á¹¹´óС£¬ÉèÖÃΪsizeof(DVSNET_CHANNEL_INFO) unsigned long dwStreamNo; //ÂëÁ÷ºÅ(ÓÃÓÚË«ÂëÁ÷) unsigned long nProtocol; //ÍøÂçЭÒé //×鲥ЭÒé HWND hWndDisplay; //ÏÔʾ´°¿Ú unsigned long bPlayStart; //ÊÇ·ñÏÔʾ 0-²»ÏÔʾ 1-ÏÔʾ unsigned long dwBackFrameCount; //»º³åÖ¡Êý unsigned long dwReserved; //±£Áô}DVSNET_CHANNEL_INFO;对比一下,大小一样的,都是28.
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
795
import
I
I
回复
0
查看
881
import
I
S
回复
0
查看
928
SUNSTONE的Delphi笔记
S
后退
顶部