如何实现c语言中的远程结构体指针?(高手请进,有点难度,在线等待……)(100分)

  • 主题发起人 主题发起人 franklei
  • 开始时间 开始时间
F

franklei

Unregistered / Unconfirmed
GUEST, unregistred user!
我用delphi中的纪录模拟c中的远程结构体指针接收传回来的数据有报错!
C中的定义如下:
typedef enum {

STREAM_VIDEO_ONLY,
STREAM_AUDIO_ONLY,
STREAM_VIDEO_AUDIO,
STREAM_UNKNOWN,

} media_stream_type_t;

typedef enum {

VIDEO_ALG_MPEG4,
VIDEO_ALG_H263,
VIDEO_ALG_UNKNOWN,

} media_video_algorithm_t;

typedef enum {

AUDIO_ALG_G711,
AUDIO_ALG_G729,
AUDIO_ALG_UNKNOWN,

} media_audio_algorithm_t;

typedef struct _FileInfoStruct
{
media_stream_type_t streamType;
struct
{
media_video_algorithm_t videoAlg;
int frameRate;
int srcWidth;
int srcHeight;
}video;

struct
{
media_audio_algorithm_t audioAlg;
}audio;

}FileInfoStruct;

调用动态库中的函数如下:
BOOL GetFileInfo(LPSTR lpFilename,FileInfoStruct* pFileInfo);
//把lpFilename文件的信息读出存储到pFileInfo结构中来


我用delphi实现如下:
type media_video_algorithm_t
= (VIDEO_ALG_MPEG4,
VIDEO_ALG_H263,
VIDEO_ALG_UNKNOWN);

type media_audio_algorithm_t
= (AUDIO_ALG_G711,
AUDIO_ALG_G729,
AUDIO_ALG_UNKNOWN);

type media_stream_type_t
= (STREAM_VIDEO_ONLY,
STREAM_AUDIO_ONLY,
STREAM_VIDEO_AUDIO,
STREAM_UNKNOWN);

type mpvideo = record

videoAlg : media_video_algorithm_t;
frameRate:integer;
srcWidth:integer;
srcHeight:integer;
end;

type mpaudio = record
audioAlg: media_audio_algorithm_t;
end;

type MPFileInfoStruct = record
streamType: integer;
video : mpvideo;
audio : mpaudio;
end;

var
fileInfor: MPFileInfoStruct
/...
GetFileInfo(pCur.filename,fileInfo); ×××
/...

我这样实现运行到×××出老是报错,而在VC中实现就没有任何问题,
我怀疑是结构定义错误,望高手指教错误之处!◎
 
GetFileInfo(pCur.filename, [blue]@[/blue]fileInfo);
 
同意楼上,是指针
 
修改了还是不行啊,
请问大侠我定义的记录类型对不对啊?
 
type
pMPFileInfoStruct = ^MPFileInfoStruct;
MPFileInfoStruct = record
streamType: integer;
video : mpvideo;
audio : mpaudio;
end;

var
pfileInfor: pMPFileInfoStruct
...
GetFileInfo(pCur.filename,pfileInfo);
 
还是不行的,真急啊,等着完成任务呢,如果哪位大虾感兴趣的,
我可以把源码寄上,帮助调试一下啊?我用的是delphi7。本人将
不胜感激,且百分奉上!
 
你那个C的结构对齐方式是什么?几字节对齐的?
你试试这个
type mpvideo = Packed record

videoAlg : media_video_algorithm_t;
frameRate:integer;
srcWidth:integer;
srcHeight:integer;
end;
 
后退
顶部