当前位置:主页>销售管理软件> 列表

请问高手这个结构体怎么转换!! 找饭店管理软件下载

库存管理软件版1楼: typedef struct _CMN5_MULTI_COMMAND {
ULONG uCommand;
ULONG uBoard;
ULONG uChannel;
union {
ULONG uParam[4];
struct {
ULONG uParam0;
ULONG uParam1;
ULONG uParam2;
ULONG uParam3;
};
};
BOOL bRet;
} CMN5_MULTI_COMMAND;
我把它转成下面的格式:
TCMN5_MULTI_COMMAND=^_CMN5_MULTI_COMMAND;
_CMN5_MULTI_COMMAND=record
uCommand :DWORD;
uBoard :DWORD;
uChannel :DWORD;
case Integer of
0:(uParam :array [0..3] of DWORD);
1:(
uParam0 :DWORD;
uParam1 :DWORD;
uParam2 :DWORD;
uParam3 :DWORD);
bRet :Boolean;
end;
可是在倒数第二个声明过不去了.提示出错信息:
Undeclared indentifier: "bRet"
Duplicate tag value
Type expected but "END" found
Could not complie used unit ''Unit1.pas''

2楼: TCMN5_MULTI_COMMAND=^_CMN5_MULTI_COMMAND;


_CMN5_MULTI_COMMAND=record
uCommand :DWORD;
uBoard :DWORD;
uChannel :DWORD;
bRet:Boolean;
case Integer of
0:(uParam :array [0..3] of DWORD);
1:(
uParam0 :DWORD;
uParam1 :DWORD;
uParam2 :DWORD;
uParam3 :DWORD;
);

end; 如管理软件免费版

3楼: 楼上这位仁兄你是有试过你的声明可用吗??这样就搞定了我就不会在这儿发帖子了.
''='' expected but '':'' found
''IMPLEMENTATION'' expected but '';'' found
''.'' expected but '';'' found
Text after final ''END.'' - ignored by compiler
Could not compile used unit ''Unit1.pas''

4楼: 顺便再问一下:UCHAR *pDataBuffer;这种的又该怎么转呢?

5楼: type
TCMN5_MULTI_COMMAND=^_CMN5_MULTI_COMMAND;
_CMN5_MULTI_COMMAND=record
uCommand :DWORD;
uBoard :DWORD;
uChannel :DWORD;
bRet :Boolean;
case Integer of
0:
(uParam:array [0..3] of DWORD);
1:
(
uParam0 :DWORD;
uParam1 :DWORD;
uParam2 :DWORD;
uParam3 :DWORD;
);
end;
没有编译错误啊。UCHAR *应该可以转换成作PCHAR类型的。

6楼: 你把bRet移到上面去,这个结构体的内存分配就不一样了.我其它的Api函数要调用它是不行的.

库存管理软件版7楼: _CMN5_MULTI_COMMAND_PARAM = record
case Integer of
0:(uParam :array [0..3] of DWORD);
1:(
uParam0 :DWORD;
uParam1 :DWORD;
uParam2 :DWORD;
uaram3 :DWORD);
end;

TCMN5_MULTI_COMMAND=^_CMN5_MULTI_COMMAND;
_CMN5_MULTI_COMMAND=record
uCommand :DWORD;
uBoard :DWORD;
uChannel :DWORD;
uParam :_CMN5_MULTI_COMMAND_PARAM;


bRet :Boolean;
end;

8楼: 楼上这位仁兄你是有试过你的声明可用吗??这样就搞定了我就不会在这儿发帖子了.
''='' expected but '':'' found
''IMPLEMENTATION'' expected but '';'' found
''.'' expected but '';'' found
Text after final ''END.'' - ignored by compiler
Could not compile used unit ''Unit1.pas''
-----
针对你这个帖子说的。wlmmlw的方法不错。

9楼: wlmmlw的方法正确,变体部分必需在记录中其他字段的声明之后,这是DELPHI的语法规则,
这点和C中的联合体不一样。

10楼: 这个数据类型是一个SDK中的定义,具体它在API函数内部是怎么调用的我不是太清楚.只想知道这样子声明在内存分配方面不会有问题吗?如果API的内部再进行一次强制转换后再调用其中的成员会不会产生其它的问题呢??请高手指点.

11楼: 用 packed record, 应该是一样的

12楼: TCMN5_MULTI_COMMAND=^_CMN5_MULTI_COMMAND;
_CMN5_MULTI_COMMAND=record
uCommand :DWORD;
uBoard :DWORD;
uChannel :DWORD;
0:(uParam :array [0..3] of DWORD);
bRet :Boolean;
end;
不要变体,pascal是不允许变体后再有其他的.
这样子声明在内存分配方面不会有问题,使用时进行一次强制转换后再调用其中的成员不会产生其它的问题 如饭店管理软件下载

13楼: 好的谢谢各位高手指点.UCHAR *pDataBuffer可以转成pDataBuffer:PChar吗??

库存管理软件版14楼: 可以

15楼: 多人接受答案了。