结构体 VS_VERSIONINFO

s446721902 2010-03-16 03:36:00

struct VS_VERSIONINFO {
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[1];
WORD Padding1[1];
VS_FIXEDFILEINFO Value;
WORD Padding2[1];
WORD Children[1];
};

按msdn上说
szKey
Contains the Unicode string "VS_VERSION_INFO".
Padding1
Contains as many zero words as necessary to align the Value member on a 32-bit boundary.
但是有一程序它这么定义的,使用的时候
VS_VERSIONINFO* pVS = (VS_VERSIONINFO*)pVer;
这个结构体里的数组能变长?
原始程序地址
http://www.codeproject.com/KB/DLL/showver.aspx
...全文
198 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
s446721902 2010-03-17
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 lhcwjy 的回复:]
struct VS_VERSIONINFO {
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[];
WORD Padding1[];
VS_FIXEDFILEINFO Value;
WORD Padding2[];
WORD Children[];
};
The VS_VERSIONINFO structure……
[/Quote]
嗯,最先给的结构就是iyige别人程序里的结构,非常像
白云飘飘飘 2010-03-16
  • 打赏
  • 举报
回复
struct VS_VERSIONINFO {
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey[];
WORD Padding1[];
VS_FIXEDFILEINFO Value;
WORD Padding2[];
WORD Children[];
};
The VS_VERSIONINFO structure depicts the organization of data in a file-version resource. It is the root structure that contains all other file-version information structures.
This structure is not a true C-language structure because it contains variable-length members. This structure was created solely to depict the organization of data in a version resource and does not appear in any of the header files shipped with the Microsoft Windows Software Development Kit (SDK).
以上是从MSDN中摘出来的,按它的说法:VS_VERSIONINFO是一个用来“描述版“本信息的结构,它并不是一个实际的结构定义。当然,实际的结构会和它很像。
stjay 2010-03-16
  • 打赏
  • 举报
回复
VS_VERSIONINFO* pVS = (VS_VERSIONINFO*)pVer;
pVer是字节流指针,并不是VS_VERSIONINFO指针
VS_VERSIONINFO结构的定义说明这字节流包含的元素,但是可能是不定长的,
其中szKey就是不确定的,Padding1是内存对齐需要,Value要重新定位的
stjay 2010-03-16
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 s446721902 的回复:]
引用 5 楼 ypb362148418 的回复:
友情Up,不懂这个

thank you
http://www.codeproject.com/KB/DLL/showver.aspx
但是这个文件缺少resource.h文件跑不起来,无法查看,悲剧啊
[/Quote]

注释掉#include "resource.h"就可以编译了
s446721902 2010-03-16
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 ypb362148418 的回复:]
友情Up,不懂这个
[/Quote]
thank you
http://www.codeproject.com/KB/DLL/showver.aspx
但是这个文件缺少resource.h文件跑不起来,无法查看,悲剧啊
ypb362148418 2010-03-16
  • 打赏
  • 举报
回复
友情Up,不懂这个
s446721902 2010-03-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cattycat 的回复:]
这个是指针转换,不是变长的问题。padding是结构体对齐加的数据成员。
[/Quote]
WCHAR szKey[1];
的值是“VS_VERSION_INFO”这个长度不是变了么?
yuzl32 2010-03-16
  • 打赏
  • 举报
回复
类型转换。
cattycat 2010-03-16
  • 打赏
  • 举报
回复
这个是指针转换,不是变长的问题。padding是结构体对齐加的数据成员。
s446721902 2010-03-16
  • 打赏
  • 举报
回复
坐等解答

64,654

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧