Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

240 lines
5.4 KiB

  1. //DATA STRUCT USED IN icon resource
  2. #define ERR_RES_INVALID_BMP 0x01
  3. #define ERR_RES_INVALID_ICON 0x02
  4. #define ERR_RES_INVALID_VER 0x04
  5. #define ERR_RES_NO_BMP 0x10
  6. #define ERR_RES_NO_ICON 0x20
  7. #define ERR_RES_NO_VER 0x40
  8. #define ERR_CANNOT_UPRES 0x100
  9. #define ERR_INVALID_BMP_MSG "�Ƿ�λͼ�ļ�, ѡ��ϵͳλͼ��"
  10. #define ERR_INVALID_ICON_MSG "�Ƿ�ͼ���ļ�, ѡ��ϵͳͼ�꣡"
  11. #define ERR_NO_BMP_MSG "ѡ��ϵͳλͼ��"
  12. #define ERR_NO_ICON_MSG "ѡ��ϵͳͼ�꣡"
  13. #define ERR_CANNOT_UPRES_MSG "�޷��������뷨��"
  14. #define MSG_TITLE "����"
  15. #define BMPNAME "CHINESE"
  16. #define ICONNAME "IMEICO"
  17. #define DATANAME "IMECHARAC"
  18. //define in imedefs.h
  19. //these are HACK CODES, and depends on imedefs.h
  20. //this code come from debug, don't change it
  21. #define STR_ID 54
  22. //according to the file size check if it is a 20*20 bmp
  23. #define BMP_20_SIZE 358
  24. typedef struct tagICONDIRENTRY{
  25. BYTE bWidth;
  26. BYTE bHeight;
  27. BYTE bColorCount;
  28. BYTE bReserved;
  29. WORD wPlanes;
  30. WORD wBitCount;
  31. DWORD dwBytesInRes;
  32. DWORD dwImageOffset;
  33. }ICONDIRENTRY;
  34. typedef struct ICONDIR{
  35. WORD idReserved;
  36. WORD idType;
  37. WORD idCount;
  38. ICONDIRENTRY idEntries[1];
  39. }ICONHEADER;
  40. #define DEFAULT_CODEPAGE 1252
  41. #define MAJOR_RESOURCE_VERSION 4
  42. #define MINOR_RESOURCE_VERSION 0
  43. #define MAXSTR (256+1)
  44. //
  45. // An ID_WORD indicates the following WORD is an ordinal rather
  46. // than a string
  47. //
  48. #define ID_WORD 0xffff
  49. //typedef WCHAR *PWCHAR;
  50. typedef struct MY_STRING {
  51. ULONG discriminant; // long to make the rest of the struct aligned
  52. union u {
  53. struct {
  54. struct MY_STRING *pnext;
  55. ULONG ulOffsetToString;
  56. USHORT cbD;
  57. USHORT cb;
  58. WCHAR *sz;
  59. } ss;
  60. WORD Ordinal;
  61. } uu;
  62. } SDATA, *PSDATA, **PPSDATA;
  63. #define IS_STRING 1
  64. #define IS_ID 2
  65. // defines to make deferencing easier
  66. #define OffsetToString uu.ss.ulOffsetToString
  67. #define cbData uu.ss.cbD
  68. #define cbsz uu.ss.cb
  69. //v-guanx 95.09.06 to avoid conflict with zhongyi
  70. #define szStr uu.ss.sz
  71. //define szStrUU uu.ss.sz
  72. typedef struct _RESNAME {
  73. struct _RESNAME *pnext; // The first three fields should be the
  74. PSDATA Name; // same in both res structures
  75. ULONG OffsetToData;
  76. PSDATA Type;
  77. ULONG SectionNumber;
  78. struct _RESNAME *pnextRes;
  79. ULONG DataSize;
  80. ULONG OffsetToDataEntry;
  81. USHORT ResourceNumber;
  82. USHORT NumberOfLanguages;
  83. WORD LanguageId;
  84. } RESNAME, *PRESNAME, **PPRESNAME;
  85. typedef struct _RESTYPE {
  86. struct _RESTYPE *pnext; // The first three fields should be the
  87. PSDATA Type; // same in both res structures
  88. ULONG OffsetToData;
  89. struct _RESNAME *NameHeadID;
  90. struct _RESNAME *NameHeadName;
  91. ULONG NumberOfNamesID;
  92. ULONG NumberOfNamesName;
  93. } RESTYPE, *PRESTYPE, **PPRESTYPE;
  94. typedef struct _UPDATEDATA {
  95. ULONG cbStringTable;
  96. PSDATA StringHead;
  97. PRESNAME ResHead;
  98. PRESTYPE ResTypeHeadID;
  99. PRESTYPE ResTypeHeadName;
  100. LONG Status;
  101. HANDLE hFileName;
  102. } UPDATEDATA, *PUPDATEDATA;
  103. //
  104. // Round up a byte count to a power of 2:
  105. //
  106. #define ROUNDUP(cbin, align) (((cbin) + (align) - 1) & ~((DWORD)(align) - 1))
  107. //
  108. // Return the remainder, given a byte count and a power of 2:
  109. //
  110. #define REMAINDER(cbin,align) (((align)-((cbin)&((align)-1)))&((align)-1))
  111. #define CBLONG (sizeof(LONG))
  112. #define BUFSIZE (4L * 1024L)
  113. //VERSION INFO related definitions
  114. //these are HACK CODES
  115. #define VER_ROOT 0
  116. #define VER_STR_INFO 1
  117. #define VER_LANG 2
  118. #define VER_COMP_NAME 3
  119. #define VER_FILE_DES 4
  120. #define VER_FILE_VER 5
  121. #define VER_INTL_NAME 6
  122. #define VER_LEGAL_CR 7
  123. #define VER_ORG_FILE_NAME 8
  124. #define VER_PRD_NAME 9
  125. #define VER_PRD_VER 10
  126. #define VER_VAR_FILE_INFO 11
  127. #define VER_TRANS 12
  128. #define VER_BLOCK_NUM 13
  129. #define VER_HEAD_LEN 0x98
  130. #define VER_TAIL_LEN 0x44
  131. #define VER_STR_INFO_OFF 0x5c
  132. #define VER_LANG_OFF 0x80
  133. #define VER_VAR_FILE_INFO_OFF 0x2c0
  134. typedef struct tagVERDATA{
  135. WORD cbBlock;
  136. WORD cbValue;
  137. WORD wKeyOffset;
  138. WORD wKeyNameSize;
  139. BOOL fUpdate; //need update flag
  140. }VERDATA;
  141. LONG
  142. AddResource(
  143. PSDATA Type,
  144. PSDATA Name,
  145. WORD Language,
  146. PUPDATEDATA pupd,
  147. PVOID lpData,
  148. ULONG cb
  149. );
  150. PSDATA
  151. AddStringOrID(
  152. LPCTSTR lp,
  153. PUPDATEDATA pupd
  154. );
  155. LONG
  156. WriteResFile(
  157. HANDLE hUpdate,
  158. char *pDstname);
  159. VOID
  160. FreeData(
  161. PUPDATEDATA pUpd
  162. );
  163. PRESNAME
  164. WriteResSection(
  165. PUPDATEDATA pUpdate,
  166. INT outfh,
  167. ULONG align,
  168. ULONG cbLeft,
  169. PRESNAME pResSave
  170. );
  171. BOOL
  172. EnumTypesFunc(
  173. HANDLE hModule,
  174. LPTSTR lpType,
  175. LONG lParam
  176. );
  177. BOOL
  178. EnumNamesFunc(
  179. HANDLE hModule,
  180. LPTSTR lpType,
  181. LPTSTR lpName,
  182. LONG lParam
  183. );
  184. BOOL
  185. EnumLangsFunc(
  186. HANDLE hModule,
  187. LPTSTR lpType,
  188. LPTSTR lpName,
  189. WORD language,
  190. LONG lParam
  191. );
  192. HANDLE BeginUpdateResourceEx(LPCTSTR,BOOL);
  193. BOOL UpdateResourceEx(HANDLE,LPCTSTR, LPCTSTR, WORD, LPVOID, DWORD);
  194. BOOL EndUpdateResourceEx(HANDLE, BOOL);
  195. /*explaination of parameters
  196. LPCTSTR pszImeDesName, //destination IME file name
  197. LPCTSTR pszImeBmpName, //Bitmap file name
  198. LPCTSTR pszImeIconName, //Icon file name
  199. LPCTSTR pszImeVerInfo, //version infomation string
  200. LPCTSTR pszImeDevCorpName, //Ime inventer corp/person name
  201. WORD wImeData //Ime initial data
  202. */
  203. BOOL ImeUpdateRes(LPCTSTR,LPCTSTR,LPCTSTR,LPCTSTR,LPCTSTR ,WORD);
  204. long MakeVerInfo(LPCTSTR,LPCTSTR,LPCTSTR,BYTE *);