编译的过程可以借助我们一直使用的编译器。
以对话框配置文件为例:
配置文件:
编译好以后就可以从目标文件中将 .data 段提取出来,从而得到理想的资源文件。
以对话框配置文件为例:
所需数据结构:
//type 宏定义
#define Dialog 0
#define Static 1
#define EditText 2
#define Button 3
#define CheckBox 4
#define RadioBotton 5
#define Image 6
#define non 7
struct control{
int type; //类型
char text[16]; //文本描述
int attr; //属性
union{
int rect[4];
struct{
int left;
int bottom;
int right;
int top;
};
};
};
#define DIALOG_BEGIN(NumOfCtrl) \
struct dialog{ \
control m_dlg; \
control m_ctrl[NumOfCtrl]; \
}; \
dialog _dlg = {
#define DIALOG_END };
配置文件:
#include "readme.h"
DIALOG_BEGIN(1)
{ Dialog,"对话框",0,0,0,10,10 },
{ Dialog,"对话框",0,0,0,10,10 },
DIALOG_END
编译好以后就可以从目标文件中将 .data 段提取出来,从而得到理想的资源文件。
在windows下目标文件格式为:coff
有时候数据段也需要进行重定位,即便这样也比自己来的轻松。