±q Windows §@·~¨t²Îªºµo®i¾ú¥v¨Ó¬Ý¡A¹Ï¥Ü ( icon ) ¦û¦³«Ü«nªº¦a¦ì¡A¥¦¥Nªí¤F¿Ë©M¾Þ§@¬É±ªº«n¨½µ{¸O¡A«U¸Ü»¡¡u¤@¹Ï¸Ñ¤d¤å¡v´N¬O³oÓ¹D²z¡C¦Û Windows 1.0 ª©¥H¨Ó¡A Windows ´N¤w¤ä´©¹Ï¥Ü¡A¨º®É¥i¥H¤ä´© 32¡Ñ32 ªº³æ¦â¹Ï¥Ü¡A¨ì¤F Windows 3.0 «h¶}©l¤ä´© 256 ¦âªº¹Ï¥Ü¡C¦Û¶i¤J Windows 9x/Me¡A¤w§â 256 ¦âªº¹Ï¥Ü§@¬°¤º©wªºÃC¦â¡A¬Æ¦Ü¥i¥H¤ä´©¨ì 65536 ¦â ( ¤]¥s°ª±m¡Ahigh color )¡C±µ¤U¨Óªº Windows XP ¨t²Î§ó¤ä´© 16777216 ¦â¡A¬Æ¦Ü¤ä´©¥b³z©ú¡C( ³æ¦â¹Ï¥Ü¨ä¹ê¬O«ü¶Â¥Õ¨â¦â¡A¥u»Ý¥Î 1 Ӧ줸´N¥i¥Hªí¥Ü¡F256 ¦â»Ýn 8 Ӧ줸¤~¯àªí¥Ü¡F65536 ºØÃC¦â«h¶· 16 ¦ì¤¸ªºªÅ¶¡¤~¥i¥HÅã¥Ü¥X¨Ó¡F16777216 ¦â«h»Ý 24 ¦ì¤¸¡A¤]¥s¥þ±m¡Atrue colors¡C§Ṳ́]±`¥Î 1 ¦ì¤¸¹Ï¥Ü¡B8 ¦ì¤¸¹Ï¥Ü¡B24 ¦ì¤¸¹Ï¤À§O¥Ü¨Óªí¥Ü³æ¦â¹Ï¥Ü¡B256 ¦â¹Ï¥Ü¡B¥þ±m¹Ï¥Ü¡C½Ð°Ñ¦Òµù¤@¡C)
Windows ©Ò¨Ï¥Îªº¹Ï¥Ü¥i¤À¬°¥|ºØ¤j¤p¡Gsystem small¡Bsystem large¡Bshell small¡Bshell large¡A¤À§O¦b¤£¦Pªº³õ¦X¤¤¨Ï¥Î¡G
·L³n«ØijÀ³¥Îµ{¦¡À³¸Ó¦b¸ê·½Àɤ¤´£¨Ñ 256 ¦â 48¡Ñ48¡B16 ¦â 32¡Ñ32¡B16 ¦â 16¡Ñ16 ¤TºØ¹Ï¥Ü³W®æ¡A¨t²Î¯à¦b³o¨Ç¹Ï¥Ü¤¤¬D¥X³Ì¾A¦Xªº¹Ï¥Ü¡AÅã¥Ü¦b¿Ã¹õ¤W¡C¦b Windows §@·~¨t²Îùتº¹Ï¥Ü¤j¦h¦s©ñ¦b¤TºØÀÉ®×ùØ¡G¥i°õ¦æÀÉ¡B°ÊºA³sµ²µ{¦¡®w»P¹Ï¥ÜÀÉùØ¡A¨ä°ÆÀɦW¤À§O¬O EXE¡BDLL¡BICO¡C¤@¯ë¦Ó¨¥¡A¦b EXE ©M DLL ùتº¹Ï¥ÜÄÝ©ó¸ê·½³¡¤À¡A¨ä§ÎºA»P ICO ¤@¼Ë¡A¦ý¬O¤ÀªR ICO Àɤñ EXE ©M DLL ®e©ö±o¦h¡A©Ò¥H¦b¥»ªþ¤¤¡A¤p¤ì°¸·|¤ÀªR ICO Àɪºµ²ºc¡A¨ÃµÛ¤â»s§@¤@ӰʺA³sµ²µ{¦¡®w¡AICONS.DLL¡A¨ä¤º¦³¤@ӰƵ{¦¡¥i¨Ñ¨ä¥Lµ{¦¡©I¥s¡A¨ä¦W¤ê¡uhIconSaveAsIco¡v¡A¥i¥H¦b¤wª¾¹Ï¥Ü¥N½X ( hIcon ) ªº±¡§Î¤U¦s¦¨¹Ï¥ÜÀÉ¡C
¤£ºÞ¬O¦s©ñ¦bþ¤@ºØÀÉ®×ùتº¹Ï¥Ü³£¬O¥¿¤è§Î¡A¨ä¤j¤p¦³ 16¡Ñ16¡B32¡Ñ32¡B48¡Ñ48¡B64¡Ñ64¡B128¡Ñ128¡B256¡Ñ256 ªº¤j¤p¡AÃC¦â¥i¥H¬O³æ¦â ( ¨ä¹ê¬O¶Â¥ÕÂù¦â )¡B16 ¦â¡B256 ¦â¤Î¥þ±m¥|ºØ¡C¦b¦¹¥¿¤è§Î¤ºªº°Ï°ì¥]§t¨âÓ³¡¤À¡G³z©ú³¡¤À»P¹Ï¤ù³¡¤À¡C¹Ï¤ù³¡¤À¥H¥~ªº°Ï°ì¬O³z©úªº¡A¥i¥H§â¹Ï¥ÜI´ºÅã²{¥X¨Ó¡C°²¦p±z§â¹Ï¥Ü©ñ¦b®à±¤W¡A¨º»ò³z©ú³¡¤À·|Åã²{¥X®à±¡A¦Ó¹Ï¤ù³¡¤À«h·|¾×¦í®à±¦ÓÅã¥X¹Ï¥Ü ( ©ÎºÙ¬°«e´º ) ¨Ó¡C¥H¤U¹Ïªº heart.ico Åã¥Ü¦b Windows XP ·´º®à±¬°¨Ò¡A¥¿¤è§Îªº¥Õ¦â¥~®Ø¬O¹Ï¥Ü°Ï°ì¡A¤ß§Î³¡¤À ( ¤]´N¬O«e´º ) «h·|¾×¦í«á±ªºI´º¡F¤ß§Î¥H¥~ªº°Ï°ì¬O³z©ú³¡¤À¡A¥i¥H¬Ý¨£Äa±V¡A¦p¤U¹Ï¥ª¡C¦pªG¥Î·Æ¹«§â¤ß§Î¹Ï¥Ü¦V¥k©ì²¾¨ì®ü±¤W¡A±z´N¯à«Ü©úÅã¬Ý¥X¨Ó³z©ú³¡¤ÀÅܦ¨®ü±¤F¡C
³o¬O«ç»ò¿ì¨ìªº©O¡Hì¨Ó¹Ï¥Ü¨ä¹ê¥]§t¤F¨â±i¹Ï¤ù¡A³o¨â±i¹Ï¤ùªº¤j¤p¬Û¦P¡A¤@±i¬O³æ¦âªº¹Ï¤ù¬O¥Ñ 0 »P 1 ºc¦¨¡AºÙ¬°¾B¸n¹Ï ( icon bitmask bitmap )¡A³z©úªº³¡¤À¬° 1¡A¤£³z©úªº³¡¤À¡A¤]´N¬O¹Ï¥Üªº«e´º¡A¬O¥H 0 ªí¥Ü¡C¦Ó¥t¤@±iºÙ¬°¦â±m¹Ï ( icon color bitmap )¡A³z©úªº³¡¤À«h¬O 0¡A«e´º¤£¬°¹s¡A¬°¦UºØÃC¦â¡C¥H¤W±¤ß§Î¹Ï¥Ü¬°¨Ò¤l¡A¦¹ heart.ico ¹Ï¥ÜÀÉùر¦³¨â±i¦ì¤¸¹Ï¡A¤@¬O¾B¸n¹Ï¡A´N¬O¤U¹Ï¥ªÃ䪺¶Â¥Õ¦ì¤¸¹Ï¡A¶Â¦â³¡¤À¬O«e´º¡A¼ÆȬ° 0¡F¥Õ¦â¬O³z©ú³¡¥÷¡A¼ÆȬ° 1¡C¥t¤@±i¬O¦â±m¹Ï¡A¶Â¦â¬O³z©ú³¡¥÷¡A¼ÆȬ° 0¡A¨ä¥L±m¦â³¡¤À§Y¬°¹Ï¥Üªº¥DÅé¡C±z¥i¥HÆ[¹î¨ì¡A¦â±m¹Ï«ê¦n¥i¥H´O¤J¾B¸n¹Ï¤¤¡C
Windows nÅã¥Ü¹Ï¥Ü®É¦³¨âÓ¨BÆJ¡A²Ä¤@¨B¡A¨t²Î·|¥ý§â®à±ªºI´º¹Ï¤ù»P¾B¸n¹Ï°µ AND ¹Bºâ¡CŪªÌÀ³ª¾¡G¥ô¦ó¼Æ»P 0 §@ AND ¹Bºâ«á¬° 0¡A¥ô¦ó¼Æ»P 1 §@ AND ¹Bºâ«á¤´¬°ì¼Æ¡A«e±©Ò»¡±o¥ô¦ó¼Æ§Yªí¥Ü®à±ªºÃC¦â¡A©Ò¥H®à±¹Ï¤ù¤£ºÞ¤°»òÃC¦â¡A»P¾B¸n¹Ï¹Bºâ«á¡A«e´º³¡¤À´NÅܬ° 0¡A§Y¶Â¦â¡F¦Ó³z©ú³¡¤Àªº¾B¸n¹Ï¬° 1¡A¬G®à±¹Ï¤ù»P¨ä¾B¸n¹Ï§@ AND ¹Bºâ«áªºµ²ªGÁÙ¬O®à±¹Ï¤ù¡A¨Ã¨S¦³§ïÅÜ¡C±z¥i¥H°Ñ¦Ò¤U¹Ï¡A·í²Ä¤@Ó¨BÆJ§¹¦¨«á¡A·|¦b¹Ï¥Üªº«e´º³¡¤À¯d¤U¶Â¦â°Ï°ì¡C
²Ä¤G¨B¬O¨Ï²Ä¤@¨Bªºµ²ªG»P¦â±m¹Ï§@ XOR ¹Bºâ¡C¥ý»¡I´º³¡¥÷¡GŪªÌÀ³ª¾¡G0 »P 0 §@ XOR ¹Bºâ±o 0¡A1 »P 0 §@ XOR ¹Bºâ±o 1¡C´«¥y¸Ü»¡¡A¥ô¦ó¼Æ»P 0 §@ XOR ªºµ²ªG¬°ì¼ÆÈ¡A©Ò¥H°µ§¹²Ä¤@Ó¨BÆJ«á¡A³z©ú³¡¤À¬°®à±¹Ï®×¡A¥i¥H¬O¥ô¦óÃC¦â ( ©Î»¡¥ô¦ó¼Æ )¡A»P¦â±m¹Ïªº³z©ú³¡¤À ( ¬° 0 ) §@ XOR «á¤´±o¨ì®à±ªºI´º¡F¦Ó«e´ºÅܬ°¶Â¦â ( §Y¬° 0 )¡A»P¦â±m¹Ïªº¹Ï¥Ü¹êÅ鳡¤À§@ XOR ¹Bºâ´N·|±o¨ì¹Ï¥Ü¹êÅé¡CŪªÌ¥i¥H°Ñ¦Ò¤U¹Ï¡G
¦]¬°¨Cӹϥܪº¾B¸n¹Ï³£·|»PI´º§@ AND ¹Bºâ¡A©Ò¥H¾B¸n¹Ï¤]ºÙ¬°¡uAND ¦ì¤¸¹Ï¡v¡F¦P²z¡A¦â±m¹Ï·|»P²Ä¤@Ó¨BÆJ«áªºµ²ªG§@ XOR ¹Bºâ¡A©Ò¥H¦â±m¹Ï¤]ºÙ¬°¡uXOR ¦ì¤¸¹Ï¡v¡C
¹Ï¥ÜÀÉ¥i¥H¥]§t¤@өΤ@Ó¥H¤Wªº¹Ï¥Ü¡A¦pªG¹Ï¥ÜÀÉùتº¹Ï¥Ü¶W¹L¤@Ó¡A¨Cӹϥܥi¥H¤£¤@¼Ë¤j¡AÃC¦â¼Æ¤]¥i¥H¤£¦P¡A³oºØ±¡§Î¤U¸û¬°½ÆÂø¡Aµy«á¦A»¡©ú¡C²{¦b¥ý»¡³Ì²³æªº¹Ï¥ÜÀÉ¡A³oºØ¹Ï¥ÜÀɬO¥u¦³¤@ӹϥܪº¡A¨äµ²ºc¦p¤U¡G
¦WºÙ | ªø«× (¦ì¤¸²Õ) |
µ²ºcÅéÄæ¦ì | »¡¡@©ú |
ICONDIR | 6 | ICONDIR STRUC idReserved WORD ? idType WORD ? idCount WORD ? ICONDIR ENDS |
idReserved ¥²¶·¬O 0¡C ¦pªG¬°¹Ï¥ÜÀÉ¡A°ÆÀɦW¬O ICO¡AidType ¬° 1¡F¦pªG¬O´å¼ÐÀÉ¡A°ÆÀɦW¬O CUR¡AidType ¬° 2 idCount ¬O ICO ÀÉ®×ùØ©Ò§t¹Ï¥ÜÓ¼Æ |
ICONDIRENTRY | 16 |
ICONDIRENTRY STRUC bWidth BYTE ? bHeight BYTE ? bColorCount BYTE ? bReserved BYTE ? wPlanes WORD ? wBitCount WORD ? dwBytesInRes DWORD ? dwImageOffset DWORD ? ICONDIRENTRY ENDS |
bWidth¡BbHeight ¤À¬O¹Ï¥Üªº¼e«×»P°ª«×¡AY¬° 0¡Aªí¥Ü¹Ï¥Ü¤j¤p¬° 256¡Ñ256 bColorCount ¬OÃC¦â¼Æ¡AYµ¥©ó 256 ¦â©Î¶W¹L¡AbColorCount ¬° 0 bReserved ¥²¶·¬O 0 wPlanes ¬OÃC¦â¥±¼Æ wBitCount ªí¥Ü¨C¤@ÂI¥]§t´XӦ줸 ( bit )¡A¦pªG¬O¶Â¥Õ¹Ï¥Ü¡A¨C¤@ÂI´N¥u»Ý¦û¥Î¤@Ӧ줸 ( µù¤@ ) dwBytesInRes ªí¥Ü¦¹¹Ï¥Ü¦û¥Î¦h¤Ö¦ì¤¸²Õ¡A¥]§t BITMAPINFOHEADER¡B½Õ¦â½L¡B¦â±m¹Ï¡B¾B¸n¹Ï¤j¤pÁ`©M dwImageOffset ªí¥Ü¦¹¹Ï¥Ü¥ÑÀÉ®×°_©l³B¶}©lºâ°_¡Aþ¤@Ӧ줸²Õ³B¶}©l¡A¥ç§Y°¾²¾¦ì§} |
BITMAPINFOHEADER | 40 | BITMAPINFOHEADER STRUC biSize DWORD ? biWidth DWORD ? biHeight DWORD ? biPlanes WORD ? biBitCount WORD ? biCompression DWORD ? biSizeImage DWORD ? biXPelsPerMeter DWORD ? biYPelsPerMeter DWORD ? biClrUsed DWORD ? biClrImportant DWORD ? BITMAPINFOHEADER ENDS |
BITMAPINFOHEADER »P¤U±ªº RGBQUAD µ²ºcÅé¦XºÙ BITMAP µ²ºcÅé¡C¦b¹Ï¥ÜÀÉùتº BITMAPINFOHEADER µ²ºcÅé»P DIB ( ¸Ë¸mµLÃöªº¦ì¤¸¹ÏÀÉ¡A¤@¯ë±`¥H BMP ©Î DIB ¬°°ÆÀɦW ) ¹ÏÀɤ¤ªº BITMAPINFOHEADER µ²ºcÅéÄæ¦ì¬Û¦P¡A¦ý¬O¹Ï¥ÜÀɪº BITMAPINFOHEADER ¥u¥Î¨ä¤¤¤»ÓÄæ¦ì¡GbiSize¡BbiWidth¡BbiHeight¡BbiPlanes¡BbiBitCount¡BbiSizeImage¡A¨ä¾lÄæ¦ì³£À³¸Ó³]¬°¹s¡C biSize ¬O BITMAPINFOHEADER µ²ºcÅé¤j¤p¡AÀ³¬° 40 Ӧ줸²Õ biWidth ¬O¹Ï¥Ü¼e«× biHeight ¬O¹Ï¥Ü°ª«×ªº¨â¿¡A³o¬O¦]¬°¹Ï¥ÜÀɤ¤ªº¦ì¤¸¸ê®Æ¬O¦â±m¹Ï¥[¤W¾B¸n¹Ï¡C biPlanes ¬OÃC¦â¥±¼Æ biBitCount ¬O¤@ÂI¦û¤F´XӦ줸¡AbiBitCount »P biPlanes ªº¼¿n§Y¬° ICONDIRENTRY µ²ºcÅ骺 bColorCount biSizeImage ¬O«ü AND ¦ì¤¸¹Ï»P XOR ¦ì¤¸¹Ï¤j¤pÁ`©M |
½Õ¦â½L | ¤£ ©T ©w ¡_ µù ¤G ¡` |
RGBQUAD STRUC rgbBlue BYTE ? rgbGreen BYTE ? rgbRed BYTE ? rgbReserved BYTE 0 RGBQUAD ENDS |
½Õ¦â½L¬O¥Ñ¼Æ¶q¤£©T©wªº RGBQUAD µ²ºcÅé©Ò²Õ¦¨¡C¹ï 16 ¦âªº¹Ï¥Ü¦Ó¨¥¡A¬Oªí¥Ü¦¹¹Ï¥Ü¥i¥H¥Î 16 ºØÃC¦âµe¥X¨Ó¡A¦Ó³o 16 ºØÃC¦â«o¬O¥i¥H¥ô·N¿ï¾Üªº¡A³o¨Ç¸ê®Æ³£°O¿ý¦b 16 Ó RGBQUAD µ²ºcÅéùØ¡C´«¨¥¤§¡A¹ï 16 ¦âªº¹Ï¥Ü¦Ó¨¥¡A´N¦³ 16 Ó RGBQUAD µ²ºcÅé²Õ¦¨½Õ¦â½L¡F¹ï 256 ¦â¹Ï¥Ü¦Ó¨¥¡A´N¦³ 256 Ó RGBQUAD µ²ºcÅé²Õ¦¨½Õ¦â½L¡C²Ä 0 Ó RGBQUAD µ²ºcÅéªí¥Ü²Ä 0 ¸¹ÃC¦â¡B²Ä 1 Ó RGBQUAD µ²ºcÅéªí¥Ü²Ä 1 ¸¹ÃC¦â¡A¦Ó©ó¨ä«áªº¦â±m¹Ï«h¬O³o¨Çµ²ºcÅéÃC¦âªº½s¸¹¡C¹ï©ó¥þ±m¹Ï¥Ü¦Ó¨¥¡A´N¤£»Ýn½Õ¦â½L¡Aª½±µ¥HÂŬõºñªí¥ÜÃC¦â¡C |
color bitmap data ( ¦â±m¹Ï¦ì¤¸¸ê®Æ ) | ¤£ ©T ©w ¡_ µù ¤T ¡` |
µù¥| | ³æ¦â¡B16 ¦â¡B256 ¦âªº¹Ï¥Ü¡A¨ä¦â±m¹Ï¤§È¶È¬O½Õ¦â½L¤§¯Á¤ÞÈ¡A¨Ã«D¹ê»Ú¦â±mÈ¡C¨Ò¦p 16 ¦âªº¹Ï¥Ü¨ä¦â±m¹Ï¬Y¼ÆȬ° 09H¡A¨Ã¤£¬O»¡ 09H ©Ò¥NªíªºÃC¦â¡A¦Ó¬O»¡¦b½Õ¦â½L²Ä 09H Ó RGBQUAD µ²ºcÅé©Ò¥NªíªºÃC¦â¡A¥Hµù¤G¬°¨Ò¡AÀ³¬°¬õ¦â¡C¥u¦³¥þ±m¹Ï¥Üªº¦â±m¹Ï¤§¼ÆÈ¡A¤~¥Nªí¦â±mÈ¡C ³æ¦â¹Ï¥Ü¨C¤@ÂI¶È¦û¥Î 1 Ӧ줸¡A¬G¤@Ӧ줸²Õ¥i¥Hªí¥Ü 8 ÓÂI¡C 16 ¦â¹Ï¥Ü¨C¤@ÂI»Ý 4 Ӧ줸ªí¥Ü¡A¬G¤@Ӧ줸²Õ¥i¥Hªí¥Ü 2 ÓÂI¡C 256 ¦â¹Ï¥Ü¨C¤@ÂI»Ý 8 Ӧ줸ªí¥Ü¡A¬G¤@Ӧ줸²Õ¶Èªí¥Ü 1 ÓÂI¡C ¥þ±m¹Ï¥Ü¨C¤@ÂI»Ý 24 Ӧ줸©Î 32 Ӧ줸ªí¥Ü¡A¬G¤@ÓÂI«on¦û¥Î 3¡ã4 Ӧ줸²Õ¡C ¤£ºÞþ¤@ºØ¹Ï¥Ü¡AÅã¥Ü¦b¿Ã¹õ¤W±ªº²Ä¤@±ø½u¡A©ñ¦b XOR ¦ì¤¸¹Ïªº³Ì«á±¡A½Ð¬Ýµù¤ªº¨Ò¤l»¡©ú¡C¦pªG¬O biHeight ¬°tÈ¡A¨º»ò¤~¬O³Ì¤W±ªº¤@±ø½u¡A¤~©ñ¦b ICO Àɪº«e±¡C |
bitmask bitmap data ( ¾B¸n¹Ï¦ì¤¸¸ê®Æ ) |
¤£ ©T ©w ¡_ µù ¤T ¡` |
µù¥| | ¾B¸n¹Ï¤Wªº¨C¤@ÓÂI¡A¥u»Ý¥Î¤@Ӧ줸 ( bit ) ªí¥Ü¡A¦ý¬O¾B¸n¹Ïªº¨C¤@±ø½u©Ò¦û¥Î¦ì¤¸²ÕӼƥ²¶·¬OÂù¦r²Õªº¾ã¼Æ¿¡C¨Ò¦p 16¡Ñ16 ¹Ï¥Ü¡A¨C¤@±ø½u¶È»Ý¦û¥Î 2 Ӧ줸²Õ¡A¦]¦¹ÁÙ»Ýn¦A¥[¤W¨âӦ줸²Õ¡A00 00 ©Î FF FF¡A¥H´ê¦¨Âù¦r²Õ¡A³o¼ËÁöµM·|¼W¥[¹Ï¥ÜªºÅé¿n¡A¦ý¬O¯à¥[§ÖÅã¥Ü³t«×¡C¸ò¦â±m¹Ïªº±Æ¦C±¡§Î¤@¼Ë¡A¾B¸n¹ÏÅã¥Ü¦b¿Ã¹õªº²Ä¤@±ø½u¡A©ñ¦b AND ¦ì¤¸¹Ïªº³Ì«á±¡A°£«D biHeight ¬°tÈ¡C |
µù¤@¡GÃC¦â¼Æ¬O wPlanes »P wBitCount ¤§¼¿n¡A»P¦û¥Î´XӦ줸ªºÃö«Y¦p¤Uªí¡G
ÃC¦â¼Æ | ¦û¥Î¦ì¤¸¼Æ | pºâ |
2 ( ¶Â¥Õ¹Ï¥Ü ) | 1 | 21 |
16 | 4 | 24 |
256 | 8 | 28 |
16777216 ( ¥þ±m ) | 24 ©Î 32 | 224 ©Î 232 |
µù¤G¡G½Õ¦â½L©Ò¦ûªº¦ì¤¸²ÕӼƨÌÃC¦â¼Æ¦Ó©w¡G
ÃC¦â½s¸¹ ( ²Ä´XÓ RGBQUAD µ²ºcÅé ) | ¼ÆÈ | ¨Ò¤l | ÃC¦â½s¸¹ ( ²Ä´XÓ RGBQUAD µ²ºcÅé ) |
¼ÆÈ | ¨Ò¤l |
00h | <000h,000h,000h,00> | ¢i¶Â¦â | 01h | <000h,000h,080h,00> | ¢i·t¬õ |
02h | <000h,080h,000h,00> | ¢i·tºñ | 03h | <000h,080h,080h,00> | ¢i´Ä¦â |
04h | <080h,000h,000h,00> | ¢i·tÂÅ | 05h | <080h,000h,080h,00> | ¢iµµ¦â |
06h | <080h,080h,000h,00> | ¢i«C¦â | 07h | <080h,080h,080h,00> | ¢i¦Ç¦â |
08h | <0c0h,0c0h,0c0h,00> | ¢i»È¦â | 09h | <000h,000h,0ffh,00> | ¢i¬õ¦â |
0ah | <000h,0ffh,000h,00> | ¢iºñ¦â | 0bh | <000h,0ffh,0ffh,00> | ¢i¶À¦â |
0ch | <0ffh,000h,000h,00> | ¢iÂŦâ | 0dh | <0ffh,000h,0ffh,00> | ¢i¯»¬õ |
0eh | <0ffh,0ffh,000h,00> | ¢i¤ÑªÅ¦â | 0fh | <0ffh,0ffh,0ffh,00> | ¢i¥Õ¦â |
µù¤T¡G¦â±m¹Ïªº¤j¤p ( ¦û¥Î¦h¤Ö¦ì¤¸²Õ ) »PÃC¦â¼Æ©M¹Ï¥Ü¤j¤p¨âÓ¦]¯À¦³Ãö¡A¦p¥k¦¡¡G¡A§¡¥i¥H¥Ñ BITMAPINFOHEADER µ²ºcÅ骺Äæ¦ìºâ¥X¨Ó¡C¦Ü©ó¾B¸n¹Ïªº¤j¤p¤ñ¸û³Â·Ð¡AÁöµM¾B¸n¹Ïªº¤j¤p¥u©M¹Ï¥Üªº¤j¤p¦³Ãö¡A¦Ó¨C¤@ÂI¥u¥Ñ¤@Ӧ줸´N¥i¥Hªí¥Ü¡A¦ý¬O¾B¸n¹Ïªº¨C¤@±ø¾î½u¥²¶·¦û¥ÎÂù¦r²Õªº¾ã¼Æ¿¡CÁ|¨Ò¨Ó»¡¡A¦pªG¬O 16¡Ñ16 ¹Ï¥Ü¡A¨C¤@±ø¾î½u¦³ 16 ÓÂI¡A¦û¥Î 2 Ӧ줸²Õ¡A©Ò¥H»Ýn¦A¥Î 2 Ó 00 ©Î 0FFH ªº¦ì¤¸²Õ¶ñº¡¡A¦¨¤@ÓÂù¦r²Õ ( §Y 4 Ӧ줸²Õ )¡A¦@¦³ 16 ±ø¾î½u¡A¦]¦¹ 16¡Ñ16 ¹Ï¥Üªº¾B¸n¹Ï¶·¦û¥Î 64 Ӧ줸²Õ ( §Y 16¡Ñ4 )¡C¦A¦p 32¡Ñ32 ¹Ï¥Üªº¾B¸n¹Ï¡A¨C¤@¾î½u¦³ 32 ÓÂI¡A«ê¦n¬O 4 Ӧ줸²Õ¡A§Y¤@ÓÂù¦r²Õ¡A¦@¦³ 32 ±ø¾î½u¡A©Ò¥H¦û¥Î 128 Ӧ줸²Õ ( §Y 32¡Ñ4 )¡C¤S¦p 48¡Ñ48 ¹Ï¥Ü¡A¨C¤@¾î½u¦³ 48 ÂI¡A¦û¥Î 6 Ӧ줸²Õ¡A¶·¦A¥H 2 Ó 00 ©Î 0FFH ªº¦ì¤¸²Õ¶ñº¡¡A¦¨¨âÓÂù¦r²Õ¡A¦@¦³ 48 ±ø¾î½u¡A©Ò¥H¦û¥Î 384 Ӧ줸²Õ ( 48¡Ñ8 )¡CÁöµM¬Ý°_¨Ó½ÆÂø¡A¦ý¼g¦¨²Õ¦X»y¨¥µ{¦¡¤ù¬q¶È¶È 6 ¦æ¡G( ³o¬qµ{¦¡¦b©³¤U ICONS.ASM ªº²Ä 127¡ã133 ¦æ )
;¨D¾B¸n¹Ï¤j¤p¡A¨Ã¦s©ónBmMaskùØ mov eax,bmih.biWidth add eax,31 shr eax,5 ;130 shl eax,2 mul bmih.biHeight mov nBmMask,eax
µù¥|¡G¦â±m¹Ï»P¾B¸n¹Ï¤£¬O¥Ñµ²ºcÅé²Õ¦¨ªº¡A¦Ó¬O¨C¤@ÂI¥Ñ¼Æ¶q¤£µ¥ªº¦ì¤¸©Ò²Õ¦¨¡C
µù¤¡G¥k¹Ï¬O¤@Ó 16 ¦â¡A16¡Ñ16 ¤j¤pªº¹Ï¥Ü¡A©ñ¤j¥H«áªº¹Ï§Î¦b©³¤U¡C¤U¹Ï¤¤¥¡ªº¶À¦â³¡¤Àªº¼Æ¦r¬O¾B¸n¹Ïªº¦ì¤¸¸ê®Æ¡A¨C¤@ÂI¨Ì¾Ú¯àÅã¥ÜI´ºªº³z©ú³¡¤À¬° 1¡A©Î¬OÅã¥Ü«e´º³¡¤À¬° 0¡C¥H²Ä¤@±ø½u¬°¨Ò¡A³Ì¥ªÃ䪺¨º¤@ÂI¬O³z©úªº¡A±µµÛªº 12 ÂI¬O¶Â¦âªº¡A³Ì¥kÃ䪺 3 ÂI¬O³z©úªº¡A¬G±o¨ì¨ä¼ÆȬ°¡u1000 0000 0000 0111¡v¡A´«ºâ¦¨¤Q¤»¶i¦ì¬°¡u80 07¡v¡C¦ý¬O¬°¤F°t¦X¦s¨ú³t²v¡A©Ò¥H¦A²K¥[¨âӦ줸²Õ¡uFF FF¡v¡A¦]¦¹²Ä¤@±ø½uÅܦ¨¡u80 00 FF FF¡v¡A¦¹Âù¦r²Õ¦s¦b ICO Àɪº¾B¸n¹Ï³Ì«á±¡A¨£¤U±¡u¹Ï¥Ü¤º®e¦Cªí¡vªº´Ä¦â©³¬õ¦â¦r³¡¤À¡C¦A¥H²Ä 7 ±ø½u¬°¨Ò¡A¥u¦³³Ì¥ªÃ䪺¤@ÂI¬O³z©ú¡A¨ä¾l§¡¬°¹Ï¥Ü«e´º¡A¬G¤G¶i¦ìªí¥Ü¬°¡u1000 0000 0000 0000¡v¡A´«ºâ¦¨¤Q¤»¶i¦ì¬°¡A¡u80 00¡v¡A¦b¤U±¹Ï¥Ü¤º®e¦Cªíªº´Ä¦â©³¥Õ¦â¦r³¡¤À¡C
¦b¤W¹Ï³Ì¥k°¼ªº¤ÑªÅ¦â©Òªí¥Üªº¼Æ¦r¬O¦â±m¹Ïªº¦ì¤¸¸ê®Æ¡A¥H²Ä 7 ±ø½u¬°¨Ò¡A¨äÃC¦â¦³¦Ç¦â¡B·tºñ¦â¡B¥Õ¦â¡A¤À§O¥Ñ½Õ¦â½L¤¤ªº²Ä 7 Ó¡B²Ä 2 Ó¡B²Ä F Ó RGBQUAD µ²ºcÅé©Òªí¥Ü¡A¬G¨ä¦â±m¹Ï¬°¡u07 2F 2F 2F FF 22 F2 27¡v¡A¦p¤Uªº·tµµ¦â©³²H¶À¦â¦rªº³¡¤À¡C¤S¦p²Ä¤@±ø½u¡A¥þ¬°¶Â¦â¡A¬O½Õ¦â½L¤¤ªº²Ä 0 ÓRGBQUAD µ²ºcÅé¡A¬G¤KӦ줸²Õ§¡¬°¹s¡A«o¬O¦w±Æ¦b¦â±m¹Ï¦ì¤¸¸ê®Æªº³Ì«á±¡A¦b¤U¹Ï¥H·tµµ¦â©³¾í¦â¦rªí¥Ü¡C
¤U±¹Ï¥Ü¤º®e¦Cªí¤@¶}©l¶Â¦Ç©³¦âªº 6 Ӧ줸²Õ¬O ICONDIR µ²ºcÅé¡A±µµÛ¬õ¦â©³¦âªº 16 Ӧ줸²Õ¬O ICONDIRENTRY µ²ºcÅé¡A¦A±µ¤U¨Óªº·tºñ©³¦â³¡¤À¬O BITMAPINFOHEADER µ²ºcÅé¡A±µµÛªºÂŦ⩳¦â³¡¤À¬O½Õ¦â½L¡A¦A¨Ó¬O·tµµ¦â©³¦â¬O¦â±m¹Ï¡A³Ì«á´Ä¦â©³¦â³¡¤À¬O¾B¸n¹Ï¡C
¹Ï¥Ü¤º®e¦Cªí¡G 000h: 00 00 01 00 01 00 10 10 10 00 01 00 04 00 28 01 010h: 00 00 16 00 00 00 28 00 00 00 10 00 00 00 20 00 020h: 00 00 01 00 04 00 00 00 00 00 C0 00 00 00 00 00 030h: 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 040h: 00 00 00 00 80 00 00 80 00 00 00 80 80 00 80 00 050h: 00 00 80 00 80 00 80 80 00 00 80 80 80 00 C0 C0 060h: C0 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00 070h: 00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00 080h: 00 00 00 00 00 07 07 FF FF FF FF FF FF F7 07 AA 090h: AF AA FF AA FF F7 07 AF AF AF AF AF AF F7 07 FA 0a0h: FF AA FF AA FF F7 07 FF FF FF FF FF FF F7 07 2F 0b0h: 2F 22 2F 2F FF 27 07 22 2F FF 2F 2F 2F 27 07 2F 0c0h: 2F F2 FF 2F 2F 27 07 2F 2F 2F FF 22 F2 27 07 F2 0d0h: FF 22 2F 2F FF 27 07 FF FF FF FF FF FF F7 07 FF 0e0h: FF FF FF FF 00 00 07 FF FF FF FF FF 7B 00 07 FF 0f0h: FF FF FF FF 70 00 00 00 00 00 00 00 00 00 80 00 100h: FF FF 80 00 FF FF 80 00 FF FF 80 00 FF FF 80 00 110h: FF FF 80 00 FF FF 80 00 FF FF 80 00 FF FF 80 00 120h: FF FF 80 00 FF FF 80 00 FF FF 80 00 FF FF 80 00 130h: FF FF 80 01 FF FF 80 03 FF FF 80 07 FF FF
¤@ӹϥÜÀɤ]¥i¥H¦P®É¥]§t¦n´XÓÃC¦â¼Æ¡B¤j¤p³£¤£¦Pªº¹Ï¥Ü¡A¦Ó¦b¹Ï¥ÜÀɤ@¶}©lªº ICONDIR µ²ºcÅé ( idCount Äæ¦ì ) ´N¼Ð©ú¤F©Ò§t¹Ï¥ÜӼơC¹Ï¥ÜÀɱµ¤U¨Óªº¤º®e´N¬O¬°¨Cӹϥܫإ߰_¸Ó¹Ï¥Üªº¸ê®Æ¡A³o¨Ç¸ê®Æ¥]§t ICONDIRENTRY µ²ºcÅé¡BBITMAPINFOHEADER µ²ºcÅé¡B½Õ¦â½L¡B¦â±m¹Ï¤Î¾B¸n¹Ï¤³¡¤À¡C¨Ò¦p¦³¤@ӹϥÜÀÉ¥]§t¤F¤TÓ¤j¤p¡BÃC¦â¼Æ¤£¦Pªº¹Ï¥Ü¡A¥¦Ì¦b ICO ÀÉ®×ùتº¦w±Æ¦p¤U¹Ï¡G
Windows XP ¤W¥«®É¡A¨äº}«Gªº¬É±¥O¤HÅåÆA¡A¥¦¤ä´© 128¡Ñ128¡B16777216 ¦âªº¥þ±m¹Ï¥Ü¡CWindows XP ªº¹Ï¥Ü®æ¦¡»P¥H«e´X¥G¬Û¦P¡A¥u¬O¦b¥þ±mªº¹Ï¥ÜùØ¥i¥H¤ä´©£\³q¹D¡C¦³¤F£\³q¹Dªº¹Ï¥Ü¡A¥i¥H¨Ï½u±ø¬Ý°_¨Ó§ó¥·Æ¡C
¦b 32 ¦ì¤¸ ( §Y¥þ±m ) ¹Ï¥Ü¡A쥻ªº¦â±m¹Ï¥H 32 ¦ì¤¸ªí¥Ü¡A«e¤TӦ줸²Õ¤À§O¥NªíÂÅ¡Bºñ¡B¬õ¤T¦âªºÃC¦â¡u±j«×¡v¡A³Ì°ª¦ì§}ªº¦ì¤¸²Õ³q±`¬O¤£¥Î¡A¦ý¬O¦b XP ¹Ï¥Ü¤¤½á¤©·sªº·N¸q¡C¥¦´N¬O£\³q¹D¡A¥Nªí¤F 0 ¨ì 255 ºØ¤£¦Pªº³z©ú«×¡A0 ªí¥Ü§¹¥þ³z©ú¡A¥ç§YÅã¥ÜI´ºÃC¦â¡F255 ªí¥Ü¤£³z©ú¡AÅã¥Ü¹Ï¥ÜÃC¦â ( ¥ç§Y«e±¤TӦ줸²ÕªºÃC¦â )¡C¹Ï¥Üªº¤TÃC¦â»PI´º¤TÃC¦â¤¬¬Û¥H¤U±¤½¦¡²V¦â¡G
¤W¦¡¶È¦C¥X¤@ÓÂIªº¬õ¦â¤À¶q¡A¦Ü©ó¨ä¥L¨âÓ¤À¶qªº²V¦â¤è¦¡¡A¤]©M¤W¦¡Ãþ¦ü¡C¦³¤F£\³q¹Dªí¥Ü³z©úµ{«×¥H«á¡A¨Æ¹ê¤W¡A¾B¸n¹Ï´N¨S¦³¦h¤j·N¸q¤F¡A©Ò¥H¦b Windows XP ¥H«áªº¨t²Î¡A¾B¸n¹Ï¥i¥H¥þ³¡¶ñ¹s¡A¦ý¬O¬°¤F©M¥H«e¨t²Îªº¬Û®e©Ê¡A³o¼Ë°µ¨Ã¤£¦n¡C
©³¤U¤p¤ì°¸±N»s§@¤@ӰʺA³sµ²µ{¦¡®w¡AICONS.DLL¡A¥¦§t¦³¤@Ó¥i¥H§â¹Ï¥Ü¥N½X¦s¦¨¹Ï¥ÜÀɪº°Æµ{¦¡¡AºÙ¬°¡uhIconSaveAsIco¡v¡C±µµÛ¤p¤ì°¸¦A¼¶¼g¤@Óµ{¦¡¡ASAVETEST.ASM¡A¥i¥HŪ¨ú 1.ICO¡A¥H±o¨ì¹Ï¥Ü¥N½X¡AµM«á¦s¦¨ 2.ICO ¹Ï¥ÜÀÉ¡A¥HÅçÃÒ¡uhIconSaveAsIco¡v¯à¥¿±`¹B§@¡C©³¤U¬O ICONS.ASM ªº¥þ³¡ì©l½X¡J
.586 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE ;°²¦p»Ýn¥Î¨ì¥]§tÀÉ¡A¨º»ò¥i¥H¦b¦¹³B©w¸q INCLUDE WINDOWS.INC INCLUDE GDI32.INC INCLUDE KERNEL32.INC INCLUDE USER32.INC INCLUDELIB GDI32.LIB INCLUDELIB KERNEL32.LIB INCLUDELIB USER32.LIB ICONDIRENTRY STRUC bWidth BYTE ? ;015 bHeight BYTE ? bColorCount BYTE ? bReserved BYTE ? wPlanes WORD ? wBitCount WORD ? ;020 dwBytesInRes DWORD ? dwImageOffset DWORD ? ICONDIRENTRY ENDS ICONDIR STRUC ;025 idReserved WORD ? idType WORD ? idCount WORD ? ICONDIR ENDS ;***************************************************************************************** .CODE ;----------------------------------------------------------------------------------------- ;¶i¤J¡þÂ÷¶}°Æµ{¦¡ªº¶i¤JÂI DLLEntry PROC hInstance,dwReason,dwReserved ;035 mov eax,TRUE ret DLLEntry ENDP ;¶i¤J¡þÂ÷¶}°Æµ{¦¡µ²§ô ;--------------------------------------------------------040------------------------------ ;hicon_save_to_ico §â hIcon ¦s¦¨¹Ï¥ÜÀÉ(¦b¤wª¾¹Ï¥Ü¥N½Xªº±¡§Î¤U¡A§âhIcon¦s¦¨ICOÀÉ) ;¿é¤J¡Ghicon¡Ð¹Ï¥Ü¥N½X ; lpIcoFile¡ÐICOÀɦW¦ì§} hicon_save_to_ico PROC USES ebx esi edi hicon:HICON,lpIcoFile:LPSTR LOCAL hFile,hDC,hMem:HANDLE ;045 LOCAL nBmColor,nBmMask,nPalette:DWORD ;¦â±m¹Ï¡B¾B¸n¹Ï¡B½Õ¦â½L¤j¤p LOCAL ii:ICONINFO LOCAL dwNumberOfBytesWritten:DWORD ;©I¥sWriteFile®É¡A¹ê»Ú¼g¤Jªº¦ì¤¸²Õ LOCAL bmih:BITMAPINFOHEADER LOCAL ide:ICONDIRENTRY ;050 LOCAL id:ICONDIR LOCAL lpBmMask,lpBmih:LPSTR ;¾B¸n¹Ï»P¦â±m¹Ï¦ì¤¸¸ê®Æ¦s©ñ¦ì§} INVOKE CreateCompatibleDC,0 or eax,eax jz error3 ;055 mov hDC,eax INVOKE CreateFile,lpIcoFile,GENERIC_WRITE,0,0,CREATE_ALWAYS,\ FILE_ATTRIBUTE_NORMAL or FILE_FLAG_WRITE_THROUGH,0 cmp eax,INVALID_HANDLE_VALUE je error2 ;060 mov hFile,eax ;³]©wICONDIRµ²ºcÅé mov id.idReserved,0 mov id.idType,1 mov id.idCount,1 ;065 ;¨ú±o¹Ï¥Üªº¸ê®Æ¡A¥Dn¬Oii.hbmColor©Mii.hbmMask¨âӦ줸¹Ï¥N½X INVOKE GetIconInfo,hicon,ADDR ii or eax,eax je error1 mov edx,ii.hbmColor ;070 mov bmih.biSize,SIZEOF BITMAPINFOHEADER mov bmih.biBitCount,0 or edx,edx jnz not_mono_0 ;YEDX¬°¹s¡Aªí¥Ü¶Â¥Õ¹Ï¥Ü¡A§ï¨ú±o¾B¸n¹Ï¸ê®Æ mov edx,ii.hbmMask ;075 not_mono_0: INVOKE GetDIBits,hDC,edx,0,0,0,ADDR bmih,DIB_RGB_COLORS or eax,eax jz error1 ;§âbmih¤¤ªº¤@¨Ç¸ê®Æ¶ñ¤Jide(¥]§tbiWidth¡BbiHeight¡BbReserved¡BbiPlanes ;¡BbiBitCount¡BdwImageOffset)ùØ 080 mov ide.dwImageOffset,SIZEOF ICONDIR+SIZEOF ICONDIRENTRY sub edx,edx mov eax,bmih.biWidth mov ebx,bmih.biHeight movzx ecx,bmih.biBitCount ;085 movzx edi,bmih.biPlanes cmp edx,ii.hbmColor jnz not_mono_1 shr ebx,1 ;Y¬°³æ¦â¹Ï¥Ü¡A¦¹®É©Ò±oªº¬O¾B¸n¹Ï¸ê®Æ mov bmih.biHeight,ebx ;¡A¥²¶·½Õ¾ãbiHeight not_mono_1: mov ide.bWidth,al mov ide.bHeight,bl mov ide.bReserved,dl mov ide.wPlanes,di mov ide.wBitCount,cx ;095 ;¨D¥X¦â±m¹Ï(XOR¦ì¤¸¹Ï)¤j¤p¡A¦s©ónBmColor mul ebx mul ecx ;EAX¡×¨CÂI¦û¥Î¦h¤Ö¦ì¤¸ shr eax,3 ;EAX¡×¨CÂI¦û¥Î¦h¤Ö¦ì¤¸²Õ mov nBmColor,eax ;100 ;ide.dwBytesInRes¡×BITMAPINFOHEADER¤j¤p¡Ï½Õ¦â½L¤j¤p¡Ï¦â±m¹Ï¤j¤p¡Ï¾B¸n¹Ï¤j¤p mov ide.dwBytesInRes,eax add ide.dwBytesInRes,SIZEOF BITMAPINFOHEADER ;¨D¥XÃC¦â¼Æ¡A¥ý¨D¥XÃC¦â¦û¦³(bmih.biBitCount*bmih.biPlanes)Ӧ줸 ;¦ýY(bmih.biBitCount*bmih.biPlanes)>8¡A«hide.bColorCount¬°0¡A ;§_«h§â1¦V¥ª²¾(bmih.biBitCount*bmih.biPlanes)¦¸ mov eax,edi mul ecx ;ECX¡×ÃC¦â¦û¦³ªº¦ì¤¸¼Æ mov ecx,eax mov ebx,1 ;110 mov eax,ebx .IF ecx<8 shl ebx,cl .ELSE sub ebx,ebx ;115 .ENDIF mov ide.bColorCount,bl ;¨D½Õ¦â½L¤j¤p¡A¨Ã¦s©ónPaletteùØ .IF cl==20h xor eax,eax ;120 ¥þ±m¡A¨S¦³½Õ¦â½L .ELSE shl eax,cl ;EAX¡×ÃC¦â¼Æ shl eax,2 ;¨CÓÃC¦â¦û¥Î¥|Ӧ줸²Õ .ENDIF mov nPalette,eax ;125 add ide.dwBytesInRes,eax ;¥[¤W½Õ¦â½L¤j¤p ;¨D¾B¸n¹Ï¤j¤p¡A¨Ã¦s©ónBmMaskùØ mov eax,bmih.biWidth add eax,31 shr eax,5 ;130 shl eax,2 mul bmih.biHeight mov nBmMask,eax add ide.dwBytesInRes,eax ;ide.dwBytesInRes¤wpºâ§¹²¦ ;¡A¦Ü¦¹¤w¶ñ§¹ICONDIRENTRYµ²ºcÅé¡A§âICONDIR¡BICONDIRENTRY¼g¤J¹Ï¥ÜÀÉ lea ecx,dwNumberOfBytesWritten INVOKE WriteFile,hFile,ADDR id,SIZEOF ICONDIR+SIZEOF ICONDIRENTRY,ecx,NULL or eax,eax jz error1 ;139 ;°t¸m°O¾ÐÅéªÅ¶¡¡A¥H¦s©ñBITMAPINFOHEADER¡B½Õ¦â½L¡B¦â±m¹Ï»P¾B¸n¹Ïªº¦ì¤¸¸ê®Æ mov ecx,80h add ecx,ide.dwBytesInRes INVOKE GlobalAlloc,GPTR,ecx or eax,eax ;145 jz error0 mov hMem,eax ;°O¾ÐÅé°Ï¶ô«e¥b³¡©ñ¦â±m¹Ï¦ì¤¸¸ê®Æ¡A±µµÛ©ñ¾B¸n¹Ï(¶Â¥Õ¹Ï¥Ü)ªº add eax,nBmColor ;¦ì¤¸¸ê®Æ¡A³Ì«á±©ñBITMAPINFOHEADER mov lpBmMask,eax ;lpBmMask¬O¾B¸n¹Ï¦ì¤¸¸ê®Æ¦ì§} add eax,nBmMask ;150 mov lpBmih,eax ;lpBmih¬OBITMAPINFOHEADER¦ì§} cld lea esi,bmih mov ecx,SIZEOF BITMAPINFOHEADER mov edi,eax ;155 rep movsb ;¨ú±ohbmColorªº¦ì¤¸¹Ï¸ê®Æ mov edx,ii.hbmColor mov ebx,hMem ;160 or edx,edx jnz not_mono_2 mov ebx,lpBmMask ;Yii.hbmColor¬°¹s¡Aªí¥Ü¶Â¥Õ¹Ï¥Ü¡A¦¹®ÉhMem©Ò¦bªº¦â±m¹Ï¦ì¤¸¸ê®Æ mov edx,ii.hbmMask ;¤w³Æ§´¡A±µµÛnot_mono_2³BnŪ¨ú¾B¸n¹Ïªº¦ì¤¸¸ê®Æ not_mono_2: INVOKE GetDIBits,hDC,edx,0,bmih.biHeight,ebx,lpBmih,DIB_RGB_COLORS or eax,eax jz error0 ;½Õ¾ãbmihªº¸ê®Æ¡G§âbiSizeImage³]¬°hbmColor¤j¤p»PhbmMask¤j¤p¤§©M¡B§âbiHeight¼¥H2¡B¨ä¥LÄæ¦ì³]¬°0 mov ebx,nBmColor add ebx,nBmMask ;170 mov edi,lpBmih xor eax,eax mov [edi+14h],ebx ;biSizeImage¡×¦â±m¹Ïªø«×¡Ï¾B¸n¹Ïªø«× shl DWORD PTR [edi+08h],1 ;¨ÏbiHeight¡×biHeight*2 mov [edi+10h],eax ;175 biCompression add edi,18h mov ecx,4 ;§âbiXPelsPerMeter¡BbiYPelsPerMeter¡BbiClrUsed¡BbiClrImportant¶ñ¤J0 rep stosd mov edx,SIZEOF BITMAPINFOHEADER lea ecx,dwNumberOfBytesWritten add edx,nPalette INVOKE WriteFile,hFile,lpBmih,edx,ecx,NULL ;§âBITMAPINFOHEADER¡B½Õ¦â½L¼g¤J¹Ï¥ÜÀÉ or eax,eax jz error0 ;184 cmp ii.hbmColor,0 jnz not_mono_3 ;¦pªG¬O¶Â¥Õ¹Ï¥Ü¡A¥un§â¦â±m¹Ï¦ì¤¸¸ê®Æ»P¾B¸n¹Ï¦ì¤¸¸ê®Æ¦s¤J¹Ï¥ÜÀɧY¥i lea ecx,dwNumberOfBytesWritten mov ebx,nBmColor ;190 add ebx,nBmMask INVOKE WriteFile,hFile,hMem,ebx,ecx,NULL or eax,eax jz error0 jmp exit_save ;195 ;«D¶Â¥Õ¹Ï¥Ü¡A¨ú±ohbmMaskªºBITMAPINFOHEADER not_mono_3: mov edi,lpBmih mov DWORD PTR [edi],SIZEOF BITMAPINFOHEADER mov WORD PTR [edi+0eh],0 ;200 INVOKE GetDIBits,hDC,ii.hbmMask,0,0,0,edi,DIB_RGB_COLORS or eax,eax jz error0 ;¨ú±ohbmMaskªº¦ì¤¸¹Ï¸ê®Æ INVOKE GetDIBits,hDC,ii.hbmMask,0,bmih.biHeight,lpBmMask,lpBmih,DIB_RGB_COLORS or eax,eax jz error0 cmp bmih.biBitCount,20h ;Àˬd¬O§_¬°32¦ì¤¸¹Ï¥Ü¡A¥u¦³32¦ì¤¸¹Ï¥Ü¤~¦³£\³q¹D jne no_alpha mov ebx,hMem ;210 sub eax,eax mov edi,ebx mov esi,lpBmMask .WHILE ebx<esi cmp BYTE PTR [ebx+3],0 ;215 je next_dword inc eax next_dword: add ebx,4 .ENDW or eax,eax ;220 YEAX¡×0¡Aªí¥Ü¥¼¨Ï¥Î£\³q¹D jnz no_alpha ;¦¹32¦ì¤¸¹Ï¥Ü¤w¨Ï¥Î£\³q¹D¡A¤£¶·½Õ¾ã .WHILE esi<lpBmih lodsb mov ecx,8 ;225 ¨CÓ¾B¸n¹Ï¦ì¤¸¸ê®Æ¦ì¤¸²Õ¦³8ÓÂI next_pixel: shl al,1 jc transparency mov BYTE PTR [edi+3],0ffh transparency: add edi,4 loop next_pixel ;230 .ENDW ;§â¦â±m¹Ï¦ì¤¸¸ê®Æ¼g¤J¹Ï¥ÜÀÉùØ no_alpha: mov ecx,nBmColor add ecx,nBmMask ;235 INVOKE WriteFile,hFile,hMem,ecx,ADDR dwNumberOfBytesWritten,NULL or eax,eax jnz exit_save error0: INVOKE GlobalFree,hMem ;240 INVOKE DeleteObject,ii.hbmColor INVOKE DeleteObject,ii.hbmMask error1: INVOKE CloseHandle,hFile INVOKE DeleteFile,lpIcoFile error2: INVOKE DeleteDC,hDC ;245 error3: mov eax,FALSE jmp exit ;ÄÀ©ñ°O¾ÐÅé°Ï¶ô¡BÃö³¬¹Ï¥ÜÀÉ¡B³]³Æ¤º®e exit_save: INVOKE GlobalFree,hMem ;250 INVOKE CloseHandle,hFile INVOKE DeleteDC,hDC mov eax,TRUE exit: ret hicon_save_to_ico ENDP ;***************************************************************************************** END DLLEntry
¼Ò²Õ©w¸qÀÉ¡AICONS.DEF¡Aªº¤º®e¦p¤U¡J
EXPORTS hIconSaveAsIco=hicon_save_to_ico VERSION 0.1
¦³¤F³o¨âÓÀɮפ§«á¡A´N¥i¥H¶}±Ò Windows ¨t²Îªº¡u©R¥O´£¥Ü¦r¤¸¡v¡A¿é¤J¥H¤U«ü¥O¡A¥H»s§@ ICONS.DLL »P ICONS.LIB¡A¨Ñ¨ä¥Lµ{¦¡©I¥s®É¨Ï¥Î¡C¸ò¥H«e¤@¼Ë¡A¤U±¨C¤@±ø«ü¥O«á³£»Ýn«ö¡uEnter¡vÁä¡A¿é¤Jµ¹¹q¸£¡A¤p¤ì°¸¥H¡u[Enter]¡vªí¥Ü¡J( ¦pªG±z¤£¤Ó¤F¸Ñ°ÊºA³sµ²µ{¦¡®wªº¸Ü¡A½Ð°Ñ¦Ò²Ä 20 ³¹ )
E:\HomePage\SOURCE\Win32\SEL_ICON>ml /c icons.asm [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: icons.asm E:\HomePage\SOURCE\Win32\SEL_ICON>link /DLL /SUBSYSTEM:WINDOWS /DEF:ICONS.DEF ICONS.OBJ [Enter] Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. Creating library ICONS.lib and object ICONS.exp E:\HomePage\SOURCE\Win32\SEL_ICON>
³Ì«á¦A¶}±Ò¤å®Ñ³B²z³nÅé¡A¿é¤J¤U±¤º®e¡G
hIconSaveAsIco PROTO hicon:HICON,lpIcoFile:LPSTR
µM«á±N¥¦¦s¦¨ ICONS.INC¡A³o¬O¥Î©ó¦b²Õ¦X»y¨¥ì©l½X¤¤¬O¥Î¨Ó«Å§i¡uhIconSaveAsIco¡vªºì«¬¡C¨ì¦¹¡AICONS.DLL ºâ¬O»s§@§¹¦¨¤F¡C
»s§@§¹ ICONS.DLL «á¡A¤p¤ì°¸¥´ºâ¦A¼¶¼g¤@µ{¦¡¡ASAVETEST.ASM¡A´ú¸Õ觹¦¨ªº ICONS.DLL¡C©³¤U¬O SAVETEST.ASM ì©l½X¡J
OPTION CASEMAP:NONE .586 .MODEL FLAT,STDCALL INCLUDE WINDOWS.INC INCLUDE GDI32.INC INCLUDE KERNEL32.INC INCLUDE USER32.INC INCLUDE SHELL32.INC INCLUDELIB GDI32.LIB INCLUDELIB KERNEL32.LIB INCLUDELIB USER32.LIB INCLUDELIB SHELL32.LIB INCLUDE ICONS.INC INCLUDELIB ICONS.LIB IDC_STATICICON EQU 5000 ;***************************************************************************************** .CONST szIconFile BYTE '1.ico',0 szSaveFile BYTE '2.ico',0 szDlgTemplate BYTE 'IconSaveTest',0 ;¹ï¸Ü²°±ªO¦WºÙ ;***************************************************************************************** .DATA hInstance HINSTANCE ? hStatic HWND ? hIcon HICON ? ;***************************************************************************************** .CODE ;----------------------------------------------------------------------------------------- DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM .IF uMsg==WM_INITDIALOG INVOKE GetDlgItem,hDlg,IDC_STATICICON mov hStatic,eax INVOKE ExtractIcon,hInstance,OFFSET szIconFile,0 mov hIcon,eax INVOKE SendMessage,hStatic,STM_SETIMAGE,IMAGE_ICON,eax INVOKE hIconSaveAsIco,hIcon,OFFSET szSaveFile .ELSEIF uMsg==WM_CLOSE INVOKE EndDialog,hDlg,NULL .ELSE mov eax,FALSE ret .ENDIF mov eax,TRUE ret DlgProc ENDP ;----------------------------------------------------------------------------------------- Start: INVOKE GetModuleHandle,NULL mov hInstance,eax INVOKE DialogBoxParam,hInstance,OFFSET szDlgTemplate,NULL,OFFSET DlgProc,NULL INVOKE ExitProcess,eax ;***************************************************************************************** END Start
¨ä¸ê·½´yzÀÉ¡ASAVETEST.RC¡A¦p¤U¡J
#include "c:\masm32\include\resource.h" #define IDC_STATICICON 5000 IconSaveTest DIALOG 0,0,204,184 STYLE DS_MODALFRAME|WS_VISIBLE|WS_CAPTION|WS_SYSMENU CAPTION "´ú¸Õ¹Ï¥Ü¦sÀÉ" FONT 8,"Arial" { CONTROL "",IDC_STATICICON,"STATIC",SS_ICON,10,10,32,32 }
±z¥i¥H¦b¡u©R¥O´£¥Ü¦r¤¸¡v¿é¤J¤U±«ü¥O²ÕĶ¥¦¡J
E:\HomePage\SOURCE\Win32\SEL_ICON>rc savetest.rc [Enter] E:\HomePage\SOURCE\Win32\SEL_ICON>ml savetest.asm /link savetest.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: savetest.asm Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "savetest.obj" "/OUT:savetest.exe" "savetest.res" E:\HomePage\SOURCE\Win32\SEL_ICON>
±z¥i¥H§â¥ô¦ó¤@ӹϥÜÀÉ«þ¨©¨ì¦¹¤l¥Ø¿ý¡A¨Ã§ó¦W¬°¡u1.ico¡v¡ASAVETEST ·|¥t¦s¤@ӹϥÜÀɮסu2.ico¡v¡C
¦b¸Ñ»¡ hIconSaveAs ¤§«e¡A¥ý¤¶²Ð³oӰƵ{¦¡·|¥Î¨ìªº API¡JExtractIcon¡BGetIconInfo¡BGetDIBits ¤TÓ¡C·íµMÁÙ¦³¤@¨Ç API ¤w¸g¦b«e±¤¶²Ð¹Lªº¡A´N¤£Åoö¤F¡C
¦bºô¸ô©Î±z¦Û¤v¹q¸£¤Wªº¹Ï¥Ü¡A¤j¦h¦s©ó DLL¡BEXE¡BICO ÀÉ®×ùØ¡A§ÚÌ¥i¥H©I¥s ExtractIcon ©Î ExtractIconEx ¨ú±o¹Ï¥Ü¥N½X¡A³o¨âÓ API ¬O¥]§t¦b SHELL32.DLL ùØ¡A¦]¦¹±o¥ý§â SHELL32.INC¡BSHELL32.LIB ¥[¶i¨Ó¡C©³¤U¬O ExtractIcon ªºì«¬¡G
INVOKE ExtractIcon,hInstance,lpszExeFileName,nIconIndex
¥ý»¡ ExtractIcon¡A¥¦¥i¥H±q lpszExeFileName ©Ò«ü¦ì§}ªºÀÉ®×ùصѨú¥X¹Ï¥Ü¨Ó¡A¨Ã½á¤©¹Ï¥Ü¥N½X¨Óªí¥Ü¦¹¹Ï¥Ü¡AÁöµM lpszExeFileName ¬Ý°_¨Ó¬O°õ¦æÀɪº¦WºÙ¡A¦ý¬O¨ä¹ê DLL ©Î ICO Àɤ]¥i¥H¡A°£¦¹¤§¥~¡A¦¹¦ì§}ªºÀɦW»Ý¥H 0 µ²§À¡C³o¨ÇÀɮצ³¥i¯à¤£¥u¤@ӹϥܡA³o®É¥H nIconIndex «ü©wn¨ú¥X²Ä´XӹϥܡAnIconIndex ¥Ñ¹s¶}©l¡FY nIconIndex ¬°¡u¡Ð1¡v¡A«h·|¨Ï ExtractIcon ¶Ç¦^Àɮפ¤¦³´XӹϥܡChInstance ¬O©I¥s ExtractIcon ªºµ{¦¡ªº°õ¦æ¹ê¨Ò¡C¦pªG©I¥s¦¨¥\¡A«h ExtractIcon ªð¦^¹Ï¥Ü¥N½X¡FYÀɮפ¤µL¹Ï¥Ü¡A«h¶Ç¦^¡u0¡v¡FY lpszExeFileName ©Ò«ü¦ì§}ªºÀɮפ£¬O EXE¡BICO¡BDLL µ¥ÀɮסA«h¶Ç¦^¡u1¡v¡C
©³¤U¦A½Í½Í ExtractIconEx¡A¨ä쫬¬°¡G
INVOKE ExtractIconEx,lpszFile,nIconIndex,phiconLarge,phiconSmall,nIcons
ExtractIconEx ¥i¥H±q lpszFile ©Ò«ü©wªºÀɦW¤¤¡AµÑ¨ú¥X nIcons ӹϥܡAµM«á§â³o¨Ç¹Ï¥Ü¥N½X¶ñ¤J phiconLarge¡BphiconSmall ©Ò«üªº°}¦C¤¤¡A«eªÌ¬O¦s©ñ¤j¹Ï¥Üªº°}¦C¡A«áªÌ¦s©ñ¤p¹Ï¥Ü°}¦C¡F¦Ü©ó¥ÑÀɮפ¤ªº²Ä´Xӹϥܶ}©lµÑ¨ú¡A¥Ñ nIconIndex «ü©w¡A¦pªG nIconIndex ¬°¡u0¡v¡Aªí¥ÜµÑ¨ú³Ì«e±ªº¹Ï¥Ü¡F¦pªG nIconIndex ¬°¡u¡Ð1¡v¥B phiconLarge¡BphiconSmall §¡¬°¹s¡Aªí¥Ü¨ú±oÀɮפº¦³´XӹϥܡCExtractIconEx ªºªð¦^È»P ExtractIcon ¬Û¦P¡C
§Ṳ́]¥i©I¥s LoadIcon ¨ú±oµ{¦¡¥»¨ªº¹Ï¥Ü¥N½X¡G
INVOKE LoadIcon,hInstance,lpIconName
hInstance ¬Oµ{¦¡ªº°õ¦æ¹ê¨Ò¡AlpIconName ¬O¸ê·½´yzÀɤ¤ªº¹Ï¥ÜÃѧO½X¡A¥i¯à¬O¼ÆȩΦr¦ê¡C¦pªGn¨ú±o Windows XP ¨t²Î¤º¹w¥ý©w¸qªº¹Ï¥Ü¡A³o®ÉÔ hInstance ³]¬° NULL¡A¦Ó lpIconName ¥i¥H¬O IDI_APPLICATION¡BIDI_ASTERISK¡BIDI_EXCLAMATION¡BIDI_HAND¡BIDI_QUESTION¡BIDI_WINLOGO¡Aµ²ªG¤À§O¬°¡B¡B¡B¡B¡B
GetIconInfo ¥i¥HÀò±o¹Ï¥Ü©Î´å¼Ðªº¸ê®Æ¡A¶È¥]§t¦â±m¹Ï»P¾B¸n¹Ïªº¹Ï¥Ü¥N½X¡CGetIconInfo API ªºì«¬¬°¡G
INVOKE GetIconInfo,hIcon,piconinfo
GetIconInfo ·|§â hIcon ªº¸ê®Æ¶ñ¤J piconinfo ©Ò«üªº¦ì§}¡A¦¹¦ì§}¦s©ñ¤@Ó¥s°µ ICONINFO ªºµ²ºcÅé¡A³oÓµ²ºcÅ骺Äæ¦ì¬O¡G
ICONINFO STRUC fIcon BOOL ? ;TRUE ªí¥Ü¹Ï¥Ü¡FFALSE ªí¥Ü´å¼Ð xHotspot DWORD ? ;´å¼Ð¼öÂIªº X ®y¼Ð¡F¹ï¹Ï¥Ü¦Ó¨¥µL·N¸q¡A¦ý³q±`¬O¹Ï¥Ü¼e«×¤@¥b yHotspot DWORD ? ;´å¼Ð¼öÂIªº Y ®y¼Ð¡F¹ï¹Ï¥Ü¦Ó¨¥µL·N¸q¡A¦ý³q±`¬O¹Ï¥Ü°ª«×¤@¥b hbmMask HBITMAP ? ;¾B¸n¹Ï¥N½X hbmColor HBITMAP ? ;¦â±m¹Ï¥N½X ICONINFO ENDS
¦pªG¦¨¥\¦a©I¥s§¹¦¨¡Aªð¦^Ȭ° TRUE¡A¨Ã¶ñ¦n ICONINFO ¤º¦UÄæ¦ì¡F¦pªG©I¥s¥¢±Ñ¡Aªð¦^ FALSE¡C¦pªG hIcon ¬O¶Â¥Õ¹Ï¥Ü¡A¨º»òªð¦^®É¡AICONINFO ùØ hbmColor Äæ¦ì¬O¹s¡A³o¬O¦]¬°¶Â¥Õ¹Ï¥Ü¨S¦³¦â±m¹Ï¡Cµ{¦¡¦¨¥\©I¥s GetIconInfo «á¡A¨t²Î·|«Ø¥ß¦â±m¹Ï¤Î¾B¸n¹Ï¥N½X¡A¦]¦¹¦pªGµ{¦¡¤£¦A¨Ï¥Î³o¨âӦ줸¹Ï®É¡AÀ³©I¥s DeleteObject §R°£¥¦Ì¡ChIcon ¤]¥i¥H¬O¨t²Î¤w¸g¹w©w¦nªº¹Ï¥Ü¡A¨Ò¦p IDC_APPSTARTING¡BIDC_ARROW¡BIDC_CROSS¡BIDC_HAND¡BIDC_HELP µ¥µ¥¡A¦pªG¬O³o¼Ëªº¸Ü¡A¤]¯à±o¨ì³o¨Ç¹w©w¹Ï¥Üªº¸ê®Æ¡C
GetDIBits ¥i¥HÀò±o¦ì¤¸¹Ïªº¦ì¤¸¸ê®Æ©M BITMAPINFO ¸ê®Æ¡A¨ä쫬¬O
INVOKE GetDIBits,hdc,hbmp,uStartScan,cScanLines,lpvBits,lpbi,uUsage
GetDIBits ¦³ÂI¨à½ÆÂø¡A¥i¤À¨â¤è±»¡¡A¤@¬O¨ú±o¦ì¤¸¸ê®Æ»P BITMAPINFO¡F¤G¬O¶È¶ÈÀò±o BITMAPINFO¡C
¥ý»¡²Ä¤@Ó¥\¯à¡Chdc ¬O³]³Æ¤º®e¡Fhbmp ¬On¨ú±o¦ì¤¸¸ê®Æªº¦ì¤¸¹Ï¥N½X¡FuStartScan ¬On±qþ¤@±ø¾î½u¶}©l¨ú±oªº¦ì¤¸¸ê®Æ¡A¥Ñ¹s¶}©l¡FcScanLines ¬O¥un¨ú±o´X±ø¾î½uªº¦ì¤¸¸ê®Æ¡FlpvBits ¬O«ü¦VÀx¦s¦ì¤¸¸ê®Æªº°O¾ÐÅé¦ì§}¡Flpbi ¬O«ü¦V BITMAPINFO µ²ºcÅé©Ò¦b¦ì§}¡FuUsage ¬O«ü©w BITMAPINFO ¤¤½Õ¦â½Lªº®æ¦¡¡A¥i¥H¨Ï¥Î¤U±¨âӨ䤤¤§¤@¡ADIB_PAL_COLORS ©Î DIB_RGB_COLORS¡A«eªÌªí¥Ü½Õ¦â½L¥Ñ«ü¦V·í«eÅÞ¿è½Õ¦âªOªº 16 ¦ì¤¸¯Á¤ÞȼƲպc¦¨¡A«áªÌªí¥Ü½Õ¦â½L¥Ñ¬õ¡Bºñ¡BÂŤTì¦âª½±µÈºc¦¨¡C¦pªG©I¥s¦¨¥\¡Aªð¦^Ȭ°¨ú±oªº¾î½u¼Æ¥Ø¡FY©I¥s¥¢±Ñ¡A«hªð¦^ FALSE¡C¦pªGµ{¦¡·Q¨ú±o hbmp ªº¦ì¤¸¸ê®Æ¡A¨º»òn¦b©I¥s«e³]©w¦n lpvBits¡A¥H¦s©ñ¦ì¤¸¸ê®Æ¡A¦P®É¤]n¥ý³]©w¦n lpbi ©Ò«ü¤§ BITMAPINFOHEADER ªº¤»ÓÄæ¦ì ( biSize¡BbiWidth¡BbiHeight¡BbiPlanes¡BbiBitCount »P biSizeImage¡CBITMAPINFO ¥]§t BITMAPINFOHEADER »P½Õ¦â½L¨â³¡¥÷ )¡C
GetDIBist ¤]¥i¥H¶È¶ÈÀò±o hbmp ªº BITMAPINFO ¸ê®Æ¡A¦¹®É¥²¶·§â lpvBits ³]¬°¹s¡A¦P®É³]©w lpbi ©Ò«ü¦ì§} BITMAPINFO µ²ºcÅ骺²Ä¤@ÓÄæ¦ì¡A¤]´N¬O biSize¡AbiSize ¬O«ü BITMAPCOREHEADER µ²ºcÅé©Î BITMAPINFOHEADER µ²ºcÅ骺¤j¤p¡Aµø±z·QÀò±oþÓµ²ºcÅé¦Ó©w¡A¤@¯ë¬O³]©w¬° BITMAPINFOHEADER ªº¤j¤p¡A¥HÀò±o¸û¦hªº¸ê®Æ¡C©I¥s GetDIBits «á¡A¨t²Î´N·|¦b lpbi ©Ò«ü BITMAPINFO ¦ì§}³B¶ñ¦n¦ì¤¸¹Ïªº¸ê®Æ¡C¦pªG©I¥s«e¡A±z¤SÅý BITMAPINFOHEADER µ²ºcÅ骺 biBitCount Äæ¦ì¬°¹s¡A¨º»ò GetDIBits ´N¶È¶È¶ñ¦n BITMAPINFOHEADER µ²ºcÅé¡A¦Ó¤£¶ñ½Õ¦â½L»P¦ì¤¸¸ê®Æ¡Cªð¦^®É¡A¦pªG©I¥s¦¨¥\¡A¨º»ò Windows 9x ·|ªð¦^Á`¦@¦³´X±ø¾î½u¡F¦Ó Windows NT/2K/XP «hªð¦^«D¹sÈ¡FY©I¥s¥¢±Ñ¡A«h Windows 9x/NT/2K/XP §¡ªð¦^ FALSE¡C
hIconSaveAsIoc ¬O¦b¤wª¾¹Ï¥Ü¥N½Xªº±¡ªp¤U¡A§â¹Ï¥Ü¥N½X¦s¦¨¶È§t¤@ӹϥܪº¹Ï¥ÜÀÉ¡A¨ä¨BÆJ²z¦p¤U¡J
³oÓ¤èªk¦³¤@¨Ç¨î¡A·í Windows ¥Ñ EXE¡BDLL ©Î ICO Àɨú±o¹Ï¥Ü®É¡A¦pªGì¨Óªº¹Ï¥Ü¤j¤p¡BÃC¦â¼Æ»P§@·~¨t²Î¤£²Å¦X®É¡A¨t²Î·|¦Û¦æ½Õ¾ã¨ì³Ì¾A¦Xªº¹Ï®×¿é¥X¡C¨Ò¦p²{¦b ( ¥Á°ê 101 ¦~ ) ±`¥Îªº§@·~¨t²Î¬O Windows XP¡A¦b¤u§@°ÏÅã¥Üªº¹Ï¥Ü¬O 32¡Ñ32¡A¥þ±m¡A¦ý¦pªG¦b DLL ùتº¹Ï¥Ü¤j¤p¥u¦³ 16¡Ñ16¡AÃC¦â¤]¥u¦³ 16 ¦â¡A¦ý¬OÅã¥Ü¦b¤u§@°Ïªº¹Ï¥Ü¤´¬O 32¡Ñ32¡A¥þ±m¡A³o¬O¨t²Î¦Û¦æ½Õ¾ã¤F¡C¦pªG¦³«e½ú°ª¤âª¾¹D¦p¦ó¦s¦¨ì©lªº¹Ï¥ÜÀÉ¡A©|½Ð¤£§[§iª¾¡C¤p¤ì°¸¦b¦¹¦hÁ¤F¡C
©³¤U¦A§ó¸Ô²Ó»¡©ú ICONS.ASM¡C
¦]¬° ICONS.ASM ¥u§â±q¤÷µ{¦¡¶Ç¨Óªº¹Ï¥Ü¥N½X¦s¦¨¤@ӹϥÜÀÉ¡A¦]¦¹ ICONDIR ªº¦UÄæ¦ì¦´N¤w¸gª¾¹D¡A¤À§O¬O 0¡B1¡B1¡Aµ{¦¡ªº²Ä 62¡ã65 ¦æ´N¬O§â³o¨ÇÄæ¦ì¶ñ¦n 0¡B1¡B1¡C¦]¦¹²Ä¤@¨B¡A¦b ICONS.ASM ¤¤¨ä¹ê¬O¤£»Ýnªº¡C
±µµÛ²Ä¤G¨B¬O ICONS.ASM ©I¥s GetIconInfo ¨ú±o¦â±m¹Ï»P¾B¸n¹Ï¥N½X ( ²Ä 67 ¦æ )¡C
¦A¨Ó§PÂ_¬O§_¬°¶Â¥Õ¹Ï¥Ü ( ²Ä 73¡ã74 ¦æ )¡A¦pªG¬O¶Â¥Õ¹Ï¥Ü¡A«h¥H¾B¸n¹Ï¥N½X©I¥s GetDIBits ( ²Ä 75 ¦æ )¡A§_«h¥H¦â±m¹Ï¥N½X©I¥s GetDIBits¡A¨Ã¦b©I¥s«e¨Ï lpvBits¡Bhbmih.biBitCount µ¥©ó¹s¡A³o¼Ë´N¯à©óªð¦^«á¡A¦b lpbi ©Ò«üªº BITMAPINFOHEADER µ²ºcÅé¦ì§}±o¨ì¦â±m¹Ïªº¼e¡B°ª¡BÃC¦âµ¥¸ê®Æ¡CICONS.ASM ·|¨Ì¾Ú³o¨Ç¸ê®Æpºâ¥X ICO Àɮפ¤ªº ICONDIRENTRY µ²ºcÅé ( ²Ä 79¡ã135 ¦æ )¡AICONDIRENTRY µ²ºcÅéùئ³ bWidth¡BbHeight¡BbColorCount¡BbReserved¡BwPlanes¡BwBitCount¡BdwBytesInRes ©M dwImageOffset ¦@¤KÓÄæ¦ì¡A¨ä¤¤ bWidth¡BbHeight¡BbReserved¡BwPlanes¡BwBitCoun ¤ÓÄæ¦ì¥i¥H¥Ñ¦â±m¹Ïªº BITMAPINFOHEADER ª½±µÀò±o ( ²Ä 81¡ã95 ¦æ )¡Cpºâ bColorCount ¤§È¡A¦b ICONS.ASM ²Ä 104¡ã117 ¦æ¡Cpºâ dwImageOffset ¤§È¸û¬°Â²³æ¡A¦bµ{¦¡ªº²Ä 81 ¦æ¡Cpºâ dwBytesInRes ¤§È¡A¸û¬°½ÆÂø¡A¦]¬° dwBytesInRes ¬O BITMAPINFOHEADER¤j¤p¡B½Õ¦â½L¤j¤p¡B¦â±m¹Ï¤j¤p¡B¾B¸n¹Ï¤j¤p¤§©M¡A¦â±m¹Ï¤j¤p¦b²Ä 96¡ã100 ¦æpºâ¥X¨Ó¡A½Õ¦â½L¤j¤p¦b²Ä 118¡ã125 ¦æpºâ¥X¨Ó¡A¾B¸n¹Ï¤j¤p¦b²Ä 127¡ã133 ¦æpºâ¥X¨Ó¡C²Ä 134 ¦æ¡A¤w¸g§â dwBytesInRes ¤§È§¹¥þ¨D¥X¨Ó¤F¡C³Ì«á¦A§â ICONDIR¡BICONDIRENTRY ¼g¤J¹Ï¥ÜÀÉùØ¡A¨£²Ä 135¡ã137 ¦æ¡C³o¼Ë²Ä¤T¨BÆJ´N§¹¦¨¤F¡C
²Ä¥|¨BÆJ¬O°t¸m°O¾ÐÅé¡A¦¹°O¾ÐÅé°Ï¶ôn®e¯Ç BITMAPINFOHEADER¡B½Õ¦â½L¡B¦â±m¹Ï»P¾B¸n¹Ïªº¦ì¤¸¸ê®Æ ( BITMAPINFO ¥]§t BITMAPINFOHEADER »P½Õ¦â½L )¡C¨ú±o³o¨Ç¸ê®Æ·íµM¬O©I¥s GetDIBits¡A¦ý¬O¤p¤ì°¸¦b¦¹µo²{¤@Ó°ÝÃD¡A¨º´N¬O¦b Windows XP ¨t²ÎùØ¡A¦pªG¨Ï¥Î 32 ¦ì¤¸ÃC¦âªº¦â±m¹Ï¥N½X¬°°Ñ¼Æ¡A©I¥s GetDIBits¡A·Ó²z»¡¦b BITMAPINFOHEADER ¤§«áÀ³¸Ó¤£·|¦³½Õ¦â½L¤~¹ï¡A¦ý¬O¹ê»Ú¤Wªð¦^«á·|¦b BITMAPINFOHEADER ¤§«á±µµÛ 3 ÓÂù¦r²Õ¡A¦ì§}¥Ñ§C¦Ó°ª¤À§O¥NªíÂÅ¡Bºñ¡B¬õ¤T¦â¡A¤p¤ì°¸¤]¤£ª¾¬OÔ£ì¦]¡A¤£¹L¹Ï¥ÜÀÉùؤ£À³§t¦³³o¨Ç¸ê®Æ¡AÀ³¤©¥H°£¥h¡F¦Ó 16¡B256 ¦â¹Ï¥Ü¡A«h¥¿±`¡A·|¦³½Õ¦â½L¡C¬°¤F¸Ñ¨M³oÓ°ÝÃD¡A¤p¤ì°¸¦b³o°t¸mªº°O¾ÐÅé¦w±Æ¤W¤£¬O·ÓµÛ ICO Àɤ¤ªº¶¶§Ç ( BITMAPINFOHEADER¡B½Õ¦â½L¡B¦â±m¹Ï¦ì¤¸¸ê®Æ¡B¾B¸n¹Ï¦ì¤¸¸ê®Æ )¡A¦Ó¬O¥ý¦s©ñ¦â±m¹Ï¦ì¤¸¸ê®Æ¡B¾B¸n¹Ï¦ì¤¸¸ê®Æ¡A¦A¦s©ñ BITMAPINFOHEADER¡B½Õ¦â½L¡C¦]¬°¦b²Ä 118¡ã125 ¦æ¤w¸g¥¿½Tªºpºâ¥X½Õ¦â½L¤j¤p¡A¨Ã¦s¦b nPalette ÅܼÆùØ¡A¥ç§Y¦pªG¬O 32 ¦ì¤¸ÃC¦â¹Ï¥Ü¡AnPalette ¬°¹s¡F¦pªG¬O¨ä¥LÃC¦â¡AnPalette ¤§È¬°¥¿½T½Õ¦â½L¤j¤p¡A©Ò¥H·ín§â BITMAPINFOHEADER¡B½Õ¦â½L¼g¤J¹Ï¥ÜÀÉùØ®É ( ²Ä 179¡ã182 ¦æ )¡A¥u»Ý§ân¼g¤Jªº¸ê®Æ¦ì§}³]¦b BITMAPINFORHEADER ©Ò¦b¦ì§}¡A¼g¤Jªº¸ê®Æªø«×¬O BITMAPINFOHEADER ¤j¤p¥[¤W nPalette §Y¥i¦Û°Ê°£¥h¦h¾lªº¤TÓÂù¦r²Õ¤S¤£¼vÅT¨ä¥LÃC¦â¹Ï¥Üªº½Õ¦â½L¡C¦¹¥~¤S¬°¤F®e¯Ç³o¦h¾lªº¤TÓÂù¦r²Õ¡A©Ò¥H¤S§â³o°O¾ÐÅé°Ï¶ô¦h¼W¥[ 80h ¦ì¤¸²Õ ( µ{¦¡²Ä 142 ¦æ )¡C°t¸m°O¾ÐÅé®É¡A©Ò°t¸m°O¾ÐÅé¤j¤p«ê¦n¬° ICONDIRENTRY µ²ºcÅ骺 dwBytesInRes Äæ¦ì¡A¦ý¦]¤Wz²z¥Ñ¡A¦A¥[¤W 80H ¦ì¤¸²Õ¡A¦Ó©Ò°t¸mªº°O¾ÐÅé¬O¥ý¥Ñ¨t²Î²M°£©Ò¦³¸ê®Æ¡A¥ç§Y§¡Åܦ¨¹s¡A³o¼Ë°µ¬O¦]¬°¶Â¥Õ¹Ï¥Üªº¦â±m¹Ï¦ì¤¸¸ê®Æ¬°¹s¡AICONS ´N¤£¶·ÃB¥~³B²z¤F¡C
µ{¦¡²Ä 141¡ã151 ¦æ¬Opºâ¦â±m¹Ï¦ì¤¸¸ê®Æ¡B¾B¸n¹Ïªº¦ì¤¸¸ê®Æ¡BBITMAPINFOHEADER ¦s©ñ¦ì§}¡A¤À§O¥H°Ï°ìÅÜ¼Æ hMem¡BlpBmMask¡BlpBmih ùØ¡CµM«á§â²Ä 76 ¦æ©Ò±oªº BITMAPINFOHEADER ¸ê®Æ²¾¨ì·s°t¸m°O¾ÐÅé°Ï¶ô¡AlpBmih ©Ò«ü¦ì§} ( ²Ä 152¡ã156 ¦æ )¡A¦A©I¥s GetDIBits ´N¯à°÷±o¨ì¦â±m¹Ï¦ì¤¸¸ê®Æ ( ²Ä 158¡ã165 ¦æ)¡C¦b©I¥s GetDIBits ¤§«e¡A¦AÀˬd¬O§_¬°¶Â¥Õ¹Ï¥Ü¡A¦pªG¬Oªº¸Ü«h¦â±m¹Ï¦ì¤¸¸ê®Æ¤w³Æ§´¡A§ï¥H¾B¸n¹Ï¥N½X©I¥s GetDIBits ( ²Ä 161¡ã164 ¦æ )¡Cµ{¦¡²Ä 168¡ã178 ¦æ¬O½Õ¾ã¦â±m¹Ï©Î¾B¸n¹Ïªº BITMAPINFOHEADER¡A¨Ï¤§Åܬ°¹Ï¥ÜÀɪº BITMAPINFOHEADER¡An½Õ¾ãªº¤º®e¦bµ{¦¡²Ä 168 ¦æªºµù¸Ñ¤w¸g»¡©ú¤F¡CµM«á¦A§â BITMAPINFO ¼g¤J¹Ï¥ÜÀÉùØ ( ²Ä 182 ¦æ )¡A¨ì¦¹¨BÆJ¥|ºâ¬O§¹¦¨¤F¡I
²Ä¤¨B¡A¤]¬O³Ì«á¤@¨BÆJ´N¬O§â¦â±m¹Ï»P¾B¸n¹Ïªº¦ì¤¸¸ê®Æ¼g¤J¹Ï¥ÜÀÉùØ¡A¦¹³B¤À¨â³¡¥÷»¡©ú¡C¥ý»¡¶Â¥Õ¹Ï¥Ü¡A¦â±m¹Ï¨Ã¤£¥Î¨ì¡A³£¬O¥H¹sªí¥Ü¡A¦b°t¸m°O¾ÐÅé®É ( ²Ä 144 ¦æ ) ´N¤w¸g³]©w¬°¹s¡A¦Ó²Ä 165 ¦æ¡A¤]¤wŪ¨ú¾B¸n¹Ïªº¦ì¤¸¸ê®Æ¤F¡A©Ò¥H¥un«ü©w¦nn¼g¤Jªº¸ê®Æ¦ì§}¤Îªø«×¡A¼g¤J¡A´N§¹¦¨¤F ( ²Ä 186¡ã195 ¦æ )¡C
¦A»¡¦pªG¤£¬O¶Â¥Õ¹Ï¥Ü¡A¥ý©I¥s GetDIBits ¨ú±o¾B¸n¹Ïªº BITMAPINFOHEADER ( ²Ä 201 ¦æ )¡Aµ¥¶ñ¦n«á¡A¦A©I¥s¤@¦¸ GetDIBits¡A´N¥i¥H±o¨ì¾B¸n¹Ï¦ì¤¸¸ê®Æ ( ²Ä 205 ¦æ )¡C±o¨ì¾B¸n¹Ï¦ì¤¸¸ê®Æ«á¡A¦A»P¦â±m¹Ï¦ì¤¸¸ê®Æ¤@°_¼g¤J¹Ï¥ÜÀÉùØ ( ²Ä 233¡ã236 ¦æ )¡A´N¤j¥\§i¦¨¡C
¤£¹L¤p¤ì°¸¥H¡uJunior Icon Editor¡v³o®M¹Ï¥Ü½s¿è¾¹´ú¸Õ¡uSAVEICON¡v©Ò»s³y¥X¨Óªº¹Ï¥ÜÀɵo²{¡A°²¦p 1.ICO ¬O 16 ¦â¹Ï¥Ü¡A¸g XP ªº¸Ë¸m¤º®eÂà´««áÅܦ¨ªº 32 ¦â¹Ï¥Ü¡AµLªk¥¿±`Åã¥Ü¡F¦ý¥t¤@®M³nÅé¡A¡uIcoFX¡v¡A«oµL¦¹°ÝÃD¡C¨s¨äì¦]¡Aì¨Ó¬O¡uJunior Icon Editor¡v·|¨Ï¥Î£\³q¹D¡C©Ò¥H¦b²Ä 208¡ã209 ¦æ¥Î¨ÓÀˬd¬O§_¬° 32 ¦â¹Ï¥Ü¡A¦pªG¤£¬O«h¤£¶·¨Ï¥Î£\³q¹D¡F¦pªG¬O 32 ¦â¹Ï¥Ü¡A¦AÀˬd¨Ï§_¤w¨Ï¥Î£\³q¹D ( ²Ä 210¡ã221 ¦æ )¡A¦pªG¤w¨Ï¥Î¤]¤£¶·½Õ¾ã¡AY¤£¨Ï¥Î£\³q¹D¤~¶·½Õ¾ã¡Aª½±µ¸õÅD¦Ü§â¦â±m¹Ï¦ì¤¸¸ê®Æ¼g¤J¹Ï¥ÜÀÉùتºµ{¦¡¤ù¬q¡C¤p¤ì°¸Àˬd¦â±m¹Ï¤¤¨CÓÂIªº³Ì«á¤@Ӧ줸²Õ¡A¦pªG§¡¬° 0¡Aªí¥Ü¨S¨Ï¥Î£\³q¹D¡A³o®É¦AÀˬd¾B¸n¹Ïªº¨CÓÂI¡A¦pªG¬O«e´º¹Ï ( ¦¹¦ì¤¸¬° 1 )¡A«h§â£\³q¹D³]¬° 0FFH¡Aªí¥Ü¤£³z©ú¡F§_«h³]¬° 0¡Aªí¥Ü³z©ú ( ²Ä 225¡ã228 ¦æ )¡C