²Ä¤C¡B¤K³¹½Í¤F¦p¦ó«Ø¥ß¨ã¦³°ò¥»¥\¯àªºÂ²³æµøµ¡¡A³o¨Ç¥\¯à¥]§t¯à¥H·Æ¹«¥ªÁä«ö¦í¼ÐÃDÄæ©ì©Ô¾ãÓµøµ¡¡B¯à¥H·Æ¹««ö¦íµøµ¡Ãä®Ø©ñ¤j©ÎÁY¤pµøµ¡¡B¦b¤u§@°Ïø»s¥X¤å¦r¡K¡Kµ¥¥\¯à¡A¦ý¦pªG¦b¤u§@°ÏÅã¥Üªº¸ê®Æ¤Ó¦h¡A¶W¥Xªº³¡¤À´NµLªk¬Ý¨ì¡C³o®ÉÔ¡A¥i¥H¦bµøµ¡¤¤¥[¤W±²°Ê¶b¡]scroll bar¡A¥ç½¦¨±²°Ê¦C¡B±²°Ê±ø¡Bºu°Ê±ø¡^¡AÅý¨Ï¥ÎªÌ¥i¥H¦V¤W¤U©Î¥ª¥k²¾°Ê¡A¥H¬Ý¨£§ó¦h¸ê®Æ¡C´N¦n¹³§Ú̥α滷ÃèÆ[¹î»·¤èª«Åé¡AÁöµM±æ»·Ã誺Ã豫ܤp¡A¯à¬Ý¨ìªºª«Å馳¡A¦ý§ÚÌ¥i¥H¦V¤W¤U©Î¥ª¥kµyµy²¾°Ê±æ»·Ãè¡A´N¯àÆ[¹î¨ì쥻¬Ý¤£¨£ªºª«Åé¡C
±²°Ê¶b¤]¬O¤@¼Ë¡A·í§Ú̾ާ@µøµ¡¥kÃ䪺¹]««±²°Ê¶b¡A°²¦p«ö¤W¤èªº±²°Ê½bÀY¡]scroll arrow¡^¡A´N¦n¹³§â±æ»·Ã詹¤W²¾°Ê¡A¥i¥H¬Ý¨£¸û¤W¤èªºª«Åé¡F«ö¤U¤èªº±²°Ê½bÀY¡A´N¦n¹³§â±æ»·Ã詹¤U²¾°Ê¡A¥i¥H¬Ý¨£¸û¤U¤èªºª«Åé¡F¤]¥i¥Hª½±µ©ì¦²±²°Ê¤è¶ô¡]thumb¡^¡A©¹¤W©Î¤U²¾°Ê¡A´N¦n¹³§â±æ»·Ã詹¤W©Î¤U²¾°Ê¦Ü©T©w¬Y³B¡C
¥»³¹ªº½d¨ÒÅã¥Ü¤F¤@¨Ç¦³Ãö¨t²Îªº¸ê®Æ¡A¦p¤U¹Ï¡A³o¨Ç¸ê®Æ³£¬O©I¥s GetSystemMetrics API ±o¨ìªº¡AGetSystemMetrics ¥u¦³¤@Ó°Ñ¼Æ nIndex¡A¦ý¬O nIndex ¥i¥H¦³ 95 ºØ¤Þ¼ÆÈ¡C³o¨Ç¤Þ¼Æ³£¦³¦WºÙ¡A¦Ó¥B¥H¡uSM_¡v¬°°_ÀY¡A¦b¡uwin64.inc¡v¥]§tÀɤ¤«Å§i¡C¨Ò¦p¤U¹Ï²Ä¤@¦Cªº²Ä¤@Äæ¬O SM_MOUSEPRESENT¡A³o¬O¤Þ¼Æ¦WºÙ¡A²Ä¤GÄæ¬O¤Þ¼ÆȬ° 19 ( ¨Æ¹ê¤W¦b win64.inc ¤¤¤w«Å§i¡uSM_MOUSEPRESENT equ 19¡v)¡A²Ä¤TÄæ¬O¤Þ¼Æªº»¡©ú¡A²Ä¥|Äæ¬O©I¥s GetSystemMetrics ªºµ²ªG¡C¦³Ãö GetSystemMetrics ªº¥Îªk½Ð°Ñ¦Ò«á±ªº»¡©ú¡C¦]¬° GetSystemMetrics ¦³ 95 ºØ¤Þ¼ÆÈ¡AµLªk¦b¤u§@°Ï¤¤¥þ³¡Åã¥Ü¥X¨Ó¡C¥[¤W¹]««±²°Ê¶b«á¡A´N¯àÅý¨Ï¥ÎªÌ¦Û¦æ¾Þ§@¡A¥HÆ[¹î¤u§@°Ï¨SÅã¥Ü¥X¨Óªº¤º®e¡C
¥J²ÓÆ[¹î¡A´N¯àµo²{¹]««±²°Ê¶b¥i¤À¬°¤Ó³¡¤À¡]¤W¹Ï¤¤¥Hµµ¦â¦r¼Ð¥Ü¨ä¦WºÙ¡^¡G
¤W¹Ïªºµøµ¡¡A¥u¦³¹]««±²°Ê¶b¡C¦ý¤j³¡¤Àªºµøµ¡¦A©³³¡ÁÙ¦³¤@Ó¤ô¥±²°Ê¶b¡A¦P¼Ë¤]¥]§t¤W±ªº¤Ó³¡¤À¡A¥\¯à¤]Ãþ¦ü¡A¥u¬O§â¤W¤U±²°Ê§ï¦¨©¹¥ª¥k¤è¦V±²°Ê¡C
·Q¦bµøµ¡¤¤«Ø¥ß±²°Ê¶b«D±`²³æ¡A¥u»Ý¦b©I¥s CreateWindowEx ®É¡A¦b²Ä¤TӰѼƤ¤¥[¤W WS_VSCROLL ´N¯à«Ø¥ß¹]««±²°Ê¶b¡A¥[¤W WS_HSCROLL ´N¯à«Ø¥ß¤ô¥±²°Ê¶b¡C·í«Ø¥ß¤F±²°Ê¶b«á¡A¤u§@°Ïªº½d³ò´N·|Åܤp¤F¡A³o¬O¦]¬°¤u§@°Ïªº½d³ò¤£¥]§t±²°Ê¶b¡C¤U±ªºµ{¦¡½X«Ø¥ß¹]««±²°Ê¶b»P¤ô¥±²°Ê¶b¡G
invoke CreateWindowEx,0,ADDR szClassName,ADDR szAppName,\
WS_OVERLAPPEDWINDOW or WS_VSCROLL or WS_HSCROLL,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,hInstance,0
¦ý¬O¶È¶È³o¼Ë¡A¥u¬O¦bµøµ¡¤ºÅã¥Ü¥X±²°Ê¶b¦Ó¤w¡F¦pªGnÅý±²°Ê¶bµo´§±²°Ê¥\¯à¡AÁÙ¥²¶·Ê¿àÃB¥~ªºµ{¦¡½X¤~¦æ¡C
³o¨ÇÃB¥~µ{¦¡½X¥²¶·³B²z¨Ï¥ÎªÌ¾Þ§@¹]««±²°Ê¶b²£¥Íªº WM_VSCROLL °T®§©Î¬O¤ô¥±²°Ê¶b²£¥Í WM_HSCROLL °T®§¡C°²¦p¤£¥[³B²z¡A¨º»ò§Y¨Ï¾Þ§@±²°Ê½bÀY¡B±²°Ê¤è¶ô©Î±²°Êy¹D¡AÃP¶}·Æ¹««á¡A±²°Ê¤è¶ôÁÙ¬O·|¸õ¦^ì¦ì¸m¡A¤u§@°Ï¤]¤£·|µo¥Í±²°Ê²{¶H¡C³o¨âÓ°T®§¤¤ªº wParam °Ñ¼Æ¤¤ 0¡ã15 ¦ì¤¸ªí¥Ü³qª¾½X¡A³o¨Ç³qª¾½X§¡¥H¡uSB_¡v( ¥Nªí scroll bar ¤§·N ) °_ÀY¡Aªí¥Ü¨Ï¥ÎªÌ¹ï±²°Ê¶b¤¤ªº¤Ó³¡¤À©Ò°µªº¾Þ§@¡A¦p¤Uªí©Ò¥Ü¡A¤]¥i¥H°Ñ¦Ò¥»³¹¤@¶}©lªº¹Ï¤¤¡AÂŦrªº»¡©ú¡G
³qª¾½X | ¼ÆÈ | »¡©ú | µe±°Ê§@ |
SB_LINEUP | 0 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¹]««±²°Ê¶b¤WºÝªº½bÀY«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¤W±²°Ê¤@¦C |
SB_LINELEFT | 0 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¤ô¥±²°Ê¶b¥ªºÝªº½bÀY«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¥ª±²°Ê¤@¦æ |
SB_LINEDOWN | 1 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¹]««±²°Ê¶b¤UºÝªº½bÀY«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¤U±²°Ê¤@¦C |
SB_LINERIGHT | 1 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¤ô¥±²°Ê¶b¥kºÝªº½bÀY«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¥k±²°Ê¤@¦æ |
SB_PAGEUP | 2 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¹]««±²°Ê¶b¤WÃ䪺±²°Êy¹D¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¤W±²°Ê¤@¶ |
SB_PAGELEFT | 2 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¤ô¥±²°Ê¶b¥ªÃ䪺±²°Êy¹D«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¥ª±²°Ê¤@¶ |
SB_PAGEDOWN | 3 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¹]««±²°Ê¶b¤UÃ䪺±²°Êy¹D¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¤U±²°Ê¤@¶ |
SB_PAGERIGHT | 3 | ¨Ï¥ÎªÌ±N·Æ¹«´å¼Ð²¾¦Ü¤ô¥±²°Ê¶b¥kÃ䪺±²°Êy¹D«á¡A«ö¤U·Æ¹«¥ªÁäµo¥X¦¹³qª¾½X | ©¹¥k±²°Ê¤@¶ |
SB_THUMBPOSITION | 4 | ¨Ï¥ÎªÌ¥H·Æ¹«©ì¦²±²°Ê¤è¶ô¡AÃP¶}·Æ¹«¥ªÁä®É¡Aµo¥X¦¹³qª¾½X¡CwParam ªº 16¡ã31 ¦ì¤¸¬°±²°Ê¤è¶ô³Ì«á¦ì¸m | ²¾¨ì±²°Ê¤è¶ôªº¨º¤@¶ |
SB_THUMBTRACK | 5 | ¨Ï¥ÎªÌ¥H·Æ¹«©ì¦²±²°Ê¤è¶ô¹Lµ{¤¤¡A·|¤£Â_µo¥X¦¹³qª¾½X¡CwParam ªº 16¡ã31 ¦ì¤¸¬°±²°Ê¤è¶ô§Y®É¦ì¸m | ²¾¨ì±²°Ê¤è¶ôªº¨º¤@¶ |
SB_ENDSCROLL | 8 | ¨Ï¥ÎªÌ§¹¦¨¾Þ§@±²°Ê¶b¡AÃP¶}·Æ¹«¥ªÁä®É¡Aµo¥X¦¹³qª¾½X | ²¾¨ì±²°Ê¤è¶ôªº¨º¤@¶ |
¥Ñ¤Wªí¥i±oª¾¡A·í¨Ï¥ÎªÌ¶È¶È¾Þ§@±²°Ê¶b¤@¦¸¡A´N·|²£¥Í³\¦h°T®§¡C¨Ò¦p¡A¨Ï¥ÎªÌ¥H·Æ¹«¥ªÁäÂIÀ»¹]««±²°Ê¶b¤WºÝªº½bÀY¤@¦¸¡A·í«ö¤U·Æ¹«¥ªÁä®É·|µo¥X³qª¾½X¬° SB_LINEUP ªº WM_VSCROLL °T®§¡AÃP¶}®É·|µo¥X³qª¾½X¬° SB_ENDSCROLL ªº WM_VSCROLL °T®§¡C
¦A¨Ò¦p¡A·í¨Ï¥ÎªÌ©ì¦²¹]««±²°Ê¶b¤Wªº±²°Ê¤è¶ô¡C¤@¶}©l¡A¨Ï¥ÎªÌ§â·Æ¹«´å¼Ð²¾¦Ü±²°Ê¤è¶ô¤W¡A«ö¤U·Æ¹«¥ªÁä®É·|µo¥X³qª¾½X¬° SB_THUMBTRACK ªº WM_VSCROLL °T®§¡Fº¸«á¦b©ì¦²¹Lµ{¤¤¡A³£¤£Â_µo¥X³qª¾½X¬° SB_THUMBTRACK ªº WM_VSCROLL °T®§¡A¦Ó¨ä wParam ªº 16¡ã31 ¦ì¤¸·|ÀHµÛ±²°Ê¤è¶ô¦ì¸m¤£¦P¦ÓÅÜ°Ê¡F³Ì«á¨Ï¥ÎªÌÃP¶}·Æ¹«¥ªÁä®É¡A·|µo¥X SB_THUMBPOSITION ªº WM_VSCROLL °T®§»P SB_ENDSCROLL ªº WM_VSCROLL °T®§¡C
·í¨Ï¥ÎªÌ©ì¦²±²°Ê¤è¶ô®É¡A¦b¹Lµ{¤¤·|²£¥Í SB_THUMBTRACK¡Aµ²§ô®É«h²£¥Í SB_THUMBPOSITION¡Cµøµ¡¨ç¦¡¤@¯ë¥u³B²z³o¨âÓ³qª¾½X¤¤ªº¨ä¤¤¤@Ó¡A¤£ºÞ³B²zþ¤@Ó³£¦U¦³Àu¯ÊÂI¡G³B²z SB_THUMBPOSITION ©Ò»Ýµ{¦¡½X¸û¬°Â²³æ¡A¦ý¨Ï¥ÎªÌ©ì¦²¹Lµ{¤u§@°Ï¤£·|Åܧó¡F³B²z SB_THUMBTRACK ¤u§@°Ï¤º®eÀH©ì¦²¹Lµ{¦Ó§ïÅÜ¡A¦ý¹q¸£¹Bºâ³t«×n°÷§Ö¤~¦æ¡]²{¦b¡A«ü¥Á°ê 112 ¦~¡A¹q¸£ªº¹Bºâ³t«×À³¸Ó¨S¦³°ÝÃD¡^¡C
¤@¯ë¦Ó¨¥¡Aµøµ¡¨ç¦¡¨Ã¤£³B²z SB_ENDSCROLL ³qª¾½X¡A¦]¬°´X¥G¨CӰʧ@µ²§ô³£·|²£¥Í¦¹³qª¾½X¡A°£«D§A·Q¯S§O³B²zÃP¶}·Æ¹«®É¸Ó°µ¤°»ò°Ê§@¡C
°£¤F SB_THUMBPOSITION¡BSB_THUMBTRACK ¤§¥~¡AwParam ªº 16¡ã31 ¦ì¤¸¤§È³£µL·N¸q¡AÀ³¸Ó©¿²¤¡C¦pªG WM_HSCROLL¡BWM_VSCROLL ¬O¥Ñ±²°Ê¶bµo¥Xªº¡A¨º»ò lParam ¬° 0¡F¦pªG¬O¥Ñ±²°Ê¶b±±¨î¶µ¡]¨£²Ä¤G¤Q¤G³¹¡^µo¥Xªº¡A¨º»ò lParam ¬O±²°Ê¶b±±¨î¶µ¥N½X¡C
¦b¤W±ªº´yz¤¤¡A¦³ÓÃöÁ䪺°ÝÃD¡A¨º´N¬O±²°Ê¤è¶ôªº¦ì¸m»P¨ä©Ò¯à²¾°Êªº½d³ò¡C·í±²°Ê¶b·s«Ø¥ß®É¡A¨t²Î¤º©w¨ä½d³ò¦b 0¡ã100 ¤§¶¡¡A¦Ó±²°Ê¤è¶ô¦ì¸m¦b 0 ªº¦a¤è¡C·íµM Windows ´£¨Ñ¤@¨Ç API ¯àÀò¨ú©Î³]©w¹ï¥¦Ìªº¸ê®Æ¡C
GetScrollRange ¥Î¨ÓÀò±o±²°Ê¤è¶ô©Ò¯à²¾°Êªº½d³ò¡A¨ä»yªk¬O¡G
invoke GetScrollRange,\ hWnd,\ ; handle of window with scroll bar nBar,\ ; scroll bar flag lpMinPos,\ ; address of variable that receives minimum position lpMaxPos ; address of variable that receives maximum position
SetScrollRange ¥Î¨Ó³]©w±²°Ê¤è¶ô©Ò¯à²¾°Êªº½d³ò¡A¨ä»yªk¬O¡G
invoke SetScrollRange,\ hWnd,\ ; handle of window with scroll bar nBar,\ ; scroll bar flag nMinPos,\ ; minimum scrolling position nMaxPos,\ ; maximum scrolling position bRedraw ; redraw flag
³o¨âÓ API ªº«e¨âӰѼƷN¸q¤@¼Ë¡A¤@¨Ö»¡©ú¡G
GetScrollRange ªº²Ä¤T¡B¥|ӰѼƬO lpMinPos¡BlpMaxPos ¤À§O¬O¨âÓªø«×¬° 32 ¦ì¤¸ªºÅܼƤ§¦ì§}¡C·í©I¥s GetScrollRange ¦¨¥\ªð¦^«á¡AWindows ·|§â±²°Ê¤è¶ô¦ì¸mªº³Ì¤p»P³Ì¤jȦs¤J³o¨âÓÅܼƤ¤¡C
SetScrollRange ªº²Ä¤T¡B¥|ӰѼƬO nMinPos¡BnMaxPos ¬O¨âÓªø«×¬° 32 ¦ì¤¸ªº¼ÆÈ¡A¥i¥H¬OÅܼƩα`¼Æ¡A¤À§O¥Nªí±²°Ê¤è¶ô¦ì¸mªº³Ì¤p»P³Ì¤jÈ¡C²Ä¤Ó°Ñ¼Æ¡AbRedraw «ü©w¬O§_n«·sø»s±²°Ê¶b¡A¥H¤ÏÀ³±²°Ê¤è¶ô§ïÅܦì¸m¡An«·sø»s bRedraw ³]¬°¤@¡A¤£«Ã¸³]¬°¹s¡C
©³¤U¬O©I¥s SetScrollRange À³ª`·Nªº¨Æ¶µ¡G①À³¥Îµ{¦¡¤£À³¸Ó¦b³B²z WM_VSCROLL ©Î WM_HSCROLL °T®§®É¡A©I¥s SetScrollRange §ïÅܱ²°Ê¶b½d³ò¡C②¦pªG¨Ï SetScrollRange ªº nMinPos ¤j©ó nMaxPos¡A·|µo¥Í¿ù»~¡F¦pªG nMinPos µ¥©ó nMaxPos¡A·|¨Ï±o±²°Ê¶bÁôÂð_¨Ó¡AÁöµM¦^¶ÇȤ´µMªí¥Ü¦¨¥\°õ¦æ¡A¤£¹L³o¨Ã«DÁôÂñ²°Ê¶bªº¦n¤èªk¡AY¯u¦³»Ýn¥²¶·ÁôÂñ²°Ê¶b¡AÀ³¸Ó©I¥s ShowScrollBar¡C③nMaxPos »P nMinPos ¤§®t¡A¥²¶·¦b MAXLONG ( MAXLONG µ¥©ó 2147483647¡A¤]´N¬O 7FFF FFFFh ) ¤§¤º¡A§_«h·|µo¥Í¿ù»~¡C④¦pªG¦b©I¥s SetScrollRange «á¡A¤S©I¥s¤F¼vÅT±²°Ê¤è¶ô¦ì¸mªº API¡A¨º»òÀ³¸Ó±N bRedraw ³]©w¬°¹s¥HÁקK¹L¦hªº«µe¡C
³o¨âÓ API ªº¦^¶Çȧ¡¤@¼Ë¡A·í©I¥s¦¨¥\®É¦^¶ÇȬ°¤@¡A¥¢±Ñ®É¦^¶ÇȬ°¹s¡C
GetScrollPos ¬O¥Î©ó¨ú±o±²°Ê¶b¤¤±²°Ê¤è¶ôªº¦ì¸m¡A¦pªG©I¥s¦¨¥\¡A¦^¶ÇÈ´N¬O±²°Ê¤è¶ôªº¦ì¸m¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬ°¹s¡C¥¦ªº»yªk¬O¡G
invoke GetScrollPos,\ hWnd,\ ; handle of window with scroll bar nBar ; scroll bar flags
SetScrollPos ¬O¥Î¨Ó³]¸m±²°Ê¶b¤¤±²°Ê¤è¶ôªº¦ì¸m¡A¨ä»yªk¬O¡G
invoke SetScrollPos,\ hWnd,\ ; handle of window with scroll bar nBar,\ ; scroll bar flag nPos,\ ; new position of scroll box bRedraw ; redraw flag
³o¨âÓ API ªº«e¨âӰѼƷN¸q¤@¼Ë¡A³£»P GetScrollRange »P SetScrollRange ¬Û¦P¡A¥i¥H°Ñ¦Ò«e±¡A©ÎªÌ©³¤Uªº»¡©ú¡G
SetScrollPos ªº²Ä¤TӰѼơAnPos «Ü©úÅã¡A´N¬On³]¸mªº±²°Ê¤è¶ô·s¦ì¸m¡C³Ì«á¤@ӰѼơAbRedraw «ü©w¬O§_n«·sø»s±²°Ê¶b¡A¥H¤ÏÀ³±²°Ê¤è¶ô§ïÅܦì¸m¡An«·sø»s bRedraw ³]¬°¤@¡A¤£«Ã¸³]¬°¹s¡C¦pªG SetScrollPos ¦¨¥\³]¸m¦n·s¦ì¸m¡A¦^¶ÇȬ°ì¥ý±²°Ê¤è¶ôªº¦ì¸m¡A¦pªG¥¢±Ñ¦^¶ÇȬ°¹s¡C
³Ì«á«Ü¯S§Oªº¬O WM_VSCROLL¡BWM_HSCROLL ¤¤ªº wParam °Ñ¼Æ¡Aªí©ú¤F±²°Ê¤è¶ô¦ì¸m¬O¤Q¤»¦ì¤¸¡A½d³ò¦b 0¡ã65535 ¤§¶¡¡C¦Ó GetScrollRange¡BSetScrollRange¡BGetScrollPos¡BSetScrollPos ¤¤ªº±²°Ê¤è¶ô¦ì¸m¬O¤T¤Q¤G¦ì¤¸¡C¹ê»Ú¤W¡AWindows ¯à³B²z 32 ¦ì¤¸ªº±²°Ê¦ì¸m¡A©Ò¥H«ez¥|Ó API ¬O¨S¦³°ÝÃDªº¡C¦pªG¬On¨Ì¿à WM_VSCROLL¡BWM_HSCROLL ¨ú±o±²°Ê¦ì¸m¡Anª`·N¶·¥ý±N³]¸m±²°Ê½d³ò¦b 0¡ã65535 ¤§¶¡¡C
©³¤U¤p¤ì°¸¹ê§@¤@Óµ{¦¡¡ASYSMTR1.ASM¡A¥¦¯à¦b¤u§@°Ï¤¤Åã¥Ü 95 µ§ªº¨t²Î¸ê®Æ¡A¨C¤@µ§¸ê®Æ³æ¿W¦û¾Ú¤@¦C¡A©Ò¥H¦³ 95 ¦C¡C¥Ñ©ó¦³³o»ò¦h¦Cªº¸ê®Æ¡A©Ò¥HµLªk¤@¦¸¥þ³£Åã¥Ü¥X¨Ó¡A¥²¶·¥[¤W¹]««±²°Ê¶b¡A¤~¯àÆ[¹î¨ì©Ò¦³ªº¸ê®Æ¡C¤]¬O¬°¤F³æ¯Â°_¨£¡A©Ò¥H¤p¤ì°¸¶È¦b SYSMTR1 ¤¤¥[¤W¹]««±²°Ê¶b¡C·í§A¾\Ū§¹¥»³¹¥B¥R¤ÀÁA¸Ñ¤§«á¡An¥[¤J¤ô¥±²°Ê¶b¤]¤£¬OÃø¨Æ¡A¥i¥H¦Û¦æ¸Õ¸Õ¡C
GetSystemMetrics ¥i¥H±o¨ì¨t²Îªº¬YºØ¸ê®Æ¡A¨Ò¦p¿Ã¹õ¼e«×¡B°ª«×µ¥¡C¥¦ªº»yªk¬O¡G
invoke GetSystemMetrics,\
nIndex ; system metric or configuration setting to retrieve
°ß¤@ªº°Ñ¼Æ¡AnIndex¡A«ü©wnÀò±o¨t²Îªºþ¤@¶µ¸ê®Æ¡A¨ä¹ê¥¦¬O¤@¨Ç¼ÆÈ¡A¦@¦³ 95 ºØ¡C³o¨Ç¼ÆÈ©Î¥iºÙ¬°¤Þ¼ÆÈ¡A¥¦Ì¤j³¡¤À¦b win64.inc ¤¤«Å§i¡A¤À§O¥H¦WºÙ¥N´À³o¨Ç¤Þ¼ÆÈ¡A¦Ó¥B§¡¥H¡uSM_¡v°_ÀY¡]system metrics ¤§·N¡^¡C¤Z¬O¡uSM_CX¡v°_ÀYªº³£¬O¬YÓªF¦èªº¼e«×¡A¦Ó¡uSM_CY¡v°_ÀYªº«h¬O°ª«×¡A³æ¦ì³£¬O¹³¯À¡]c ¬O counter ¤§·N¡AX¡BY ¥»¬O¾î®y¼Ð»PÁa®y¼Ð¡A³o¸Ì¥Nªí¼e«×»P°ª«×¡^¡C©Î³\¥H«á·sªº§@·~¨t²Î¼W¥[¤Þ¼ÆªººØÃþ¡A¦ý¤p¤ì°¸¦b¼¶¼g³o¤@³¹®É¡A¬d¾\ªº¬O·L³nºô¯¸¤Wªº¸ê®Æ¡A´N¥u¦³ 95 ºØ¡A©³¤Uªºªí¥u¦C¥X´XºØ¦Ó¤w¡G
nIndex¡]¤Þ¼Æ¡^ | ¤Þ¼ÆÈ | »¡©ú |
SM_CXSCREEN | 0 | ¿Ã¹õ¼e«×¦³¦h¤Ö¹³¯À |
SM_CYSCREEN | 1 | ¿Ã¹õ°ª«×¦³¦h¤Ö¹³¯À |
SM_CYMENU | 15 | ¥\¯àªí°ª«×¦³¦h¤Ö¹³¯À |
SM_MOUSEPRESENT | 19 | ¦pªG°t³Æ·Æ¹«¡A¦^¶ÇȬ° 1¡F¤Ï¤§¬° 0 |
SM_SWAPBUTTON | 23 | ·Æ¹«¥ª¥kÁä¬O§_¥æ´«¥\¯à¡A¦pªG¥æ´«¡A¦^¶ÇȬ° 1¡F¤Ï¤§¬° 0 |
°²¦pn¦bµøµ¡ªº¤u§@°Ï¤¤¡A¹³¥»³¹¤@¶}©lªº¹Ï¤ù¨º¼Ë¡A§â GetSystemMetrics ªº¤Þ¼Æ¦WºÙ¡B¤Þ¼ÆÈ¡B¤Þ¼Æ»¡©ú¡B¦^¶Çȵ¥¸ê®Æ¤À¦¨¥|ÄæÅã¥Ü¡A¨º»òÁÙn¤@¨ÇÃB¥~ªº¸ê®Æ¡A¥Ñ©ó³o¨Ç¸ê®Æ«Ü¦h¡A¦]¦¹¥t¥~Àx¦s¦b SYSMTR.INC ¥]§tÀɸ̡C¦¹¥]§tÀɺ¥ýn¦³ 95 ºØ¤Þ¼ÆÈ¡A³o 95 ºØ¤Þ¼Æȳ£¬O¥H¡uSM_¡v¬°¶}ÀYªº±`¼Æ¡A¦b SYSMTR.INC ¤¤¬°¤@Ó¦r²Õªø«×¡F²Ä¤G¬O³o¨Ç¤Þ¼Æªº¦WºÙ¡A¥¦Ì³£¬O¤j¼g^¤å¦r¥À²Õ¦¨ªº¦r¦ê¡A¦Ó¥B³£¥H¡uSM_¡v¬°¶}ÀY¡A¥H¹s¬°µ²§À¡F²Ä¤T¬O¹ï³o¨Ç¤Þ¼Æªº»¡©ú¡A¤]´N¬O»¡¦W¨ú±o¦óºØ¨t²Î¸ê®Æ¡C¨C¤@µ§¸ê®Æ³£¦³³o¤T³¡¤À¡A³£©ñ¦bµ{¦¡ªº¸ê®Æ°Ï¬q¡A.CONST¡A¤¤¡C©³¤U¬O SYSMTR.INC ªº¤@³¡¤À¡G
.CONST n00 DW SM_CXSCREEN DB "SM_CXSCREEN",0,"Primary display width",0 n01 DW SM_CYSCREEN DB "SM_CYSCREEN",0,"Primary display height",0 n02 DW SM_CXVSCROLL DB "SM_CXVSCROLL",0,"Vertical scroll bar width",0 n03 DW SM_CYHSCROLL DB "SM_CYHSCROLL",0,"Horizontal scroll bar height",0 n04 DW SM_CYCAPTION DB "SM_CYCAPTION",0,"Caption area height",0 ⁝
¦]¬°¨C¤@µ§¸ê®Æªø«×§¡¤£©T©w¡A¤£®e©ö¦s¨ú¡A¦]¦¹¦b SYSMTR.INC ¸Ì±¡Aºò±µµÛ«ez¸ê®Æ¤§«á¡A¬O¨C¤@µ§¸ê®Æªº°_©l¦ì§}¡A¹³©³¤Uªº¼Ë¤l¡G
aryPt DQ n00,n01,n02,n03,n04¡K¡Kn94
¤W±ªº aryPt ¬O¥Ñ¨C¤@µ§¸ê®Æªº°_©l¦ì§}©Ò²Õ¦¨ªº¸ê®Æ¡A¨ä¹ê´N¬O°}¦C¡C¦³Ãö°}¦Cªº¥Îªk¡A½Ð°Ñ¾\«á±ªº»¡©ú¡C¤£¹L³o¸Ì¨Ã«D¯uªº¤@µ§¤@µ§ªº¿é¤J¡unXX,nYY¡K¡K¡v¡A¦Ó¬O¥H©³¤Uªº¥¨¶°µ{¦¡¼g¥X¤W±ªº°}¦C¡C²¦³º¡An¼g 95 Ó¤¸¯À¤Ó³Â·Ð¤F¡I
aryPt LABEL QWORD j=0 WHILE j LT LINES IF @SizeStr(%j) EQ 1 temp TEXTEQU @CatStr(<n0>,%j) ;;Yj<10¡Atemp="n01"+j¡A¦]¬°j¥u¦³Ó¦ì¼Æ ELSE temp TEXTEQU @CatStr(<n>,%j) ;;Yj>=10¡Atemp="n"+j¡A¦]¬°j¬°¨â¦ì¼Æ ENDIF DQ temp j=j+1 ENDM
¦b¤u§@°Ï¤¤¦L¥X¤å¦r¡A¥i¥H§Q¥Î¤W¤@³¹¤¶²Ðªº DrawText¡A¦ý³o¤@³¹¤p¤ì°¸¥´ºâ¤¶²Ð¥t¤@Ó API¡ATextOut¡A¨Ó°µ³o¥ó¨Æ¡CTextOut ¤£¶·«ü©w°ÅµôÁ|¦æ¡A¥u»Ý«ü©w¤u§@°Ï¤¤ªº¬YÓ®y¼Ð¬°°ò·ÇÂI¡A¦r¦ê¥H¦¹°ò·ÇÂI¦L¥X¨Ó¡A¤ñ DrawText ³æ¯Â¡CTextOut ªº¥Îªk¬O¡G
invoke TextOut,\ hdc,\ ; handle to DC nXStart,\ ; x-coordinate of starting position nYStart,\ ; y-coordinate of starting position lpString,\ ; character string cbString ; number of characters
hdc ²@µLºÃ°Ý¬O¸Ë¸m¤º®e¥N½X¡Aø»sªº¤å¦r±N¦b¦¹¸Ë¸m¤º®e¤¤Åã¥Ü¡F¥i¥H¬O©I¥s GetDC ©Î BeginPaint «áªº¦^¶ÇÈ¡CnXStart¡BnYStart ¤À§O¬O°ò·ÇÂIªº X ®y¼Ð»P Y ®y¼Ð¡ClpString ¬O¦r¦ê¦ì§}¡CcbSring ¬O¦r¦êªø«×¡A³æ¦ì¬O¦r¤¸Ó¼Æ¡C
SetTextAlign ¬O¥Î¨Ó³]¸m°ò·ÇÂI¦p¦ó¨Ï¥Î¡C¥ý¬Ý¬Ý¥¦ªº»yªk¡G
invoke SetTextAlign,\ hdc,\ ;handle of device context fMode ;text-alignment flag
«Ü©úÅã¡Ahdc ¬O¸Ë¸m¤º®e¥N½X¡CfMode ¬O¤å¦r±Æ¦C¤è¦¡¡A¥i¥H¨Ï¥Îªº±Æ¦C¤è¦¡¦³¤U±´XºØ¡G
fMode | »¡©ú |
TA_BASELINE | ¤å¦rªº°ò·Ç½u¡]baseline¡A¨£ GetTextMetrics ªº¹Ï¡^¦ì©ó°ò·ÇÂI |
TA_BOTTOM | ¤å¦r¤U½t¦ì©ó°ò·ÇÂI |
TA_TOP | ¤å¦r¤W½t¦ì©ó°ò·ÇÂI |
TA_CENTER | ¤å¦r¤ô¥¤è¦Vªº¤¤¤ßÂI¦ì©ó°ò·ÇÂI |
TA_LEFT | ¤å¦r¥ª½t¦ì©ó°ò·ÇÂI |
TA_RIGHT | ¤å¦r¥k½t¦ì©ó°ò·ÇÂI |
TA_NOUPDATECP | ·í«e¦ì¸m¤£§ïÅÜ |
TA_UPDATECP | ¥H·í«e¦ì¸m§@¬°°ò·ÇÂI¡A¥B·í«e¦ì¸m·|§ïÅÜ |
·í¨Ï¥Î¤F TA_UPDATECP «á¡ATextOut ´N·|©¿²¤ nXStart¡BnYStart¡A¦Ó¥H·í«e¦ì¸m¬°°ò·ÇÂI¡F¦Ó°õ¦æ§¹ TextOut «á¡A·í«e¦ì¸m´N·|Åܦ¨¦r¦êµ²§Àªº¦ì¸m¡C·í«e¦ì¸m¤@¶}©l¬O¦b¤u§@°Ï¥ª¤W¨¤ªº®y¼Ð¡A( 0, 0 )¡Aªº¦ì¸m¡A¥i¥H¸g©I¥s MoveToEx¡BLineTo µ¥§ïÅÜ¡A©Î¬O¨Ï¥Î TA_UPDATECP ¬°°Ñ¼Æ©I¥s SetTextAlign ¤Î TextOut¡A¤]¯à§ïÅÜ·í«e¦ì¸m¡C
¦pªG¦¨¥\°õ¦æ§¹ SetTextAlign¡A¦^¶ÇȬOì¨Ó³]©wªº¤å¦r±Æ¦C¤è¦¡¡F¦pªG¥¢±Ñ¡A¦^¶ÇȬO GDI_ERROR¡A¥i©I¥s GetLastError ±o¨ì§ó·Ç½Tªº¿ù»~ì¦]¡C
¨Ò¦p¥k¹Ï¤u§@°Ï¤¤¡A¥H SetTextAlign »P TextOut ø»sªº¨âÓ¦r¦ê¡G¦r¦ê¡u¥ª¤â«üµÛ¤ë¡A¥k¤â¨ú¬õ½u¡vªº°ò·ÇÂI¬O (10,10)¡A¦ì©ó¦r¦êªº¥ª¤W¨¤¡F¦Ó¦r¦ê¡u½ç¤©§A©M§Ú¦pÄ@ªº±¡½t¡C¡vªº°ò·ÇÂI¬O (200,50)¡A¦ì©ó¦r¦êªº¥k¤U¨¤¡Cµ{¦¡½X¦p¤U¡G
invoke SetTextAlign,hdc,TA_TOP or TA_LEFT invoke TextOut,hdc,10,10,"¥ª¤â«üµÛ¤ë¡A¥k¤â¨ú¬õ½u",22 invoke SetTextAlign,hdc,TA_BOTTOM or TA_RIGHT invoke TextOut,hdc,200,50,"½ç¤©§A©M§Ú¦pÄ@ªº±¡½t¡C",22
¨¥Âk¥¿¶Ç¡C·í SYSMTR1 §â¦UÓ GetSysytemMetrics ªº¤Þ¼Æ¦WºÙ¡B¤Þ¼ÆÈ¡B¤Þ¼Æ»¡©ú¤Î¦^¶ÇȤÀ¦¨¥|Äæ¦L¦b¤u§@°Ï¤º¡A«Ü©úÅã¡A¦L¥Xªº²Ä¹s¦C¦r¦ê¥ª¤W¨¤®y¼Ð¬O ( 0, 0 )¡F²Ä¤@¦C¦r¦êªº¥ª¤W¨¤ X ®y¼Ð¬° 0¡AY ®y¼Ð´NÀ³¸Ó¬O¤W¤@¦Cªº Y ®y¼Ð¥[¤W¨C¤@¦C¤å¦rªº°ª«×¡F²Ä¤G¦C¦r¦êªº¥ª¤W¨¤ X ®y¼ÐÁÙ¬O 0¡AY ®y¼Ð¬O«e¤@¦Cªº Y ®y¼Ð¦A¥[¤W¨C¤@¦C¤å¦rªº°ª«×¡K¡K¨Ì¦¹Ãþ±À¡A«K¥iª¾¨C¦C¤å¦rªº¥ª¤W¨¤ X ®y¼Ð§¡¬° 0¡AY ®y¼Ð¬°²Ä´X¦C¼¥H¨C¦C¤å¦rªº°ª«×¡A³o¸Ìªº²Ä´X¦C¬O¥Ñ¹s¶}©l¡C
°£¦¹¤§¥~¡A¨C¤@Ä檺¼e«×»P¦r¤¸¦h¹è¤Î¦r¤¸¼e«×¦³Ãö¡C°ò©ó¤W±ì¦]¡A¥²¶·¨ú±o¦r¤¸°ª«×¤Î¦r¤¸¼e«×¡C¦r¤¸¤S¥i¤À¬°©T©w¼e«×ªº¦r¤¸¤Î¥iÅܼe«×ªº¦r¤¸¡A¹³¤¤¤å¦r¡B¡uCourier New¡v¡B¡uAnonymous Pro¡vµ¥ÄÝ©ó©T©w¼e«×¦r¤¸¡A¥¦ªº^¤å¦r¥À¡uI¡v»P¡uM¡vµ¥¼e¡C¹³¡uTimes New Roman¡v´NÄÝ©ó¥iÅܼe«×¦r¤¸¡A¥¦ªº^¤å¦r¥À¡uI¡vªº¼e«×¤ñ¡uM¡v¯¶«Ü¦h¡C
¨º»ò«ç»òÀò±o¦r¤¸ªº°ª«×»P¼e«×©O¡H«Ü²³æ¡A©I¥s GetTextMetrics §Y¥i¡CGetTextMetrics ¦³¨âӰѼơA©I¥s¤èªk¦p¤U¡G
invoke GetTextMetrics,\ hdc,\ ; handle of device context lptm ; address of text metrics structure
¥ý»¡²Ä¤GӰѼơAlptm¡A¬O«ü¦V¤@ÓºÙ¬° TEXTMETRIC µ²ºcÅ骺¦ì§}¡A³oÓµ²ºcÅé¥Î¨Ó±µ¦¬¥Ñ GetTextMetrics ¶Ç¦^¨Ó¦³Ãö¤å¦rªº¤Ø¤oµ¥¸ê®Æ¡CTEXTMETRIC ¦UÄæ¦ì¦p¤U¡G
TEXTMETRIC STRUCT tmHeight SDWORD ? ; ¦r¤¸°ª«×¡A¨£¥k¤U¹Ï Height ªº¹³¯À tmAscent SDWORD ? ; ¥k¤U¹Ï Ascent ªº¹³¯À tmDescent SDWORD ? ; ¥k¤U¹Ï Descent ªº¹³¯À tmInternalLeading SDWORD ? ; ¥k¤U¹Ï InternalLeading ªº¹³¯À tmExternalLeading SDWORD ? ; ¥k¤U¹Ï ExternalLeading ªº¹³¯À tmAveCharWidth SDWORD ? ; ¦r¤¸ªº¥§¡¼e«× tmMaxCharWidth SDWORD ? ; ¦r§Î¤¤³Ì¼e¦r¤¸ªº¼e«× tmWeight SDWORD ? tmOverhang SDWORD ? tmDigitizedAspectX SDWORD ? tmDigitizedAspectY SDWORD ? tmFirstChar BYTE ? tmLastChar BYTE ? tmDefaultChar BYTE ? tmBreakChar BYTE ? tmItalic BYTE ? tmUnderlined BYTE ? tmStruckOut BYTE ? tmPitchAndFamily BYTE ? tmCharSet BYTE ? TEXTMETRIC ENDS
TEXTMETRIC ªº¦¨û¤Ó¦h¡A©Ò¥H¶È¤¶²Ð SYSMTR1 ·|¥Î¨ìªº¡G
¨ä¤¤È±oª`·Nªº¬O¡A¦pªG¬O¥iÅܼe«×ªº¦r§Î¡A¤j¼g¦r¥Àªº¼e«×¬O¦r¤¸¥§¡¼e«×ªº 1.5 ¿¡F¦pªG¬O©T©w¼e«×ªº¦r§Î¡A¤j¼g¦r¥Àªº¼e«×´N¬O¦r¤¸ªº¥§¡¼e«×¡C
hdc ¬O¸Ë¸m¤º®e¥N½X¡CWindows ¤¹³\¸Ë¸m¤º®e¤¤¨Ï¥Î¤£¦P¦r§Îø»s¤å¦r¡A¦ý SYSMTR1 ¤¤¥u¨Ï¥Î Windows ¤º©wªº¦r§Î¡A¤]´N¬O SYSTEM_FONT¡A³oºØ¦r§Î¤]¥Î©ó¼ÐÃDÄæ¡B¿ï³æ©M¹ï¸Ü²°¤¤Åã¥Ü¦r¦ê¡C¦]¬° SYSMTR1 ¨S¦³§ó´«¦r§Î¡A©Ò¥H¥i¥H¦bµøµ¡¤@«Ø¥ß¤§®É¡A¦b WM_CREATE ¤¤¨ú±o¤@¦Cªº°ª«×¡C
·íÀ³¥Îµ{¦¡©I¥s CreateWindowEx «Ø¥ßµøµ¡«á¦ý©|¥¼Åã¥Ü©ó¿Ã¹õ«e¡A§@·~¨t²Î´N·|¹ïÀ³¥Îµ{¦¡ªºµøµ¡¨ç¦¡µo¥X¤@«h WM_CREATE °T®§¡CWM_CREATE °T®§¬Oµøµ¡¨ç¦¡³Ì¦¦¬¨ìªº°T®§¤§¤@¡A³B²z¦¹°T®§®É³q±`¬O°µªì©l¤Æªº¤u§@¡C¦pªGÀ³¥Îµ{¦¡n³B²z¦¹°T®§¡A³B²z§¹²¦À³±N¦^¶Çȳ]¬°¹s¡F¦pªG¤£³B²z¦¹°T®§¡A«h¥æ¥Ñ DefWindowProc ³B²z¡F¦pªG±N¦^¶Çȳ]¬°¡Ð1¡A·|µ²§ôÀ³¥Îµ{¦¡¡C
¦b SYSMTR1 µ{¦¡¤¤´N¬O©ó³B²z¦¹°T®§®É¡A©I¥s GetTextMetrics¡A¨D±o¦r¤¸¼e«×¡B¨C¤@¦C°ª«×¡A¶i¦Ópºâ¥X¨C¤@Äæ°_©l¦ì¸mªº X ®y¼Ð¡C°ÝÃD¬O GetTextMetrics ªº²Ä¤@ӰѼƴN¬O¸Ë¸m¤º®e¥N½X¡A«e±´£¹L¦b WM_PAINT ¥i¥H©I¥s BeginPaint ¨ú±o¸Ë¸m¤º®e¥N½X¡A¨º»ò¦b WM_CREATE ¦p¦óÀò±o¸Ë¸m¤º®e¥N½X©O¡H³o¤]¤£Ãø¡A¥i¥H©I¥s GetDC¡CGetDC ¥i¥H¦b³B²z¤£¬O WM_PAINT °T®§¤¤¡AÀò±o¸Ë¸m¤º®e¥N½X¡A·íµM¦b³B²z§¹¬ÛÃö§@·~«á¥²¶·©I¥s ReleaseDC¡AÄÀ©ñ¸Ë¸m¤º®e¥H¸`¬ù¸ê·½¡C
·Qn¦b³B²z«D WM_PAINT °T®§¤¤Àò±o¸Ë¸m¤º®e¥N½X¡A¥i¥H©I¥s GetDC¡A¥¦¥u¦³¤@ӰѼơA´N¬On¨ú±o¸Ë¸m¤º®eªºµøµ¡¥N½X¡A¦^¶ÇÈ´N¬O¸Ë¸m¤º®e¥N½X¡A¦pªG¥¢±Ñ¦^¶ÇȬ° 0¡CGetDC ªºì«¬¬O¡G
invoke GetDC,\ hWnd ; handle of window invoke ReleaseDC,\ hWnd,\ ; handle of window hDC ; handle of device context
ReleaseDC «h¬OÄÀ©ñ hWnd ªº¸Ë¸m¤º®e¡A¦pªG¦¨¥\¦^¶ÇȬ° 1¡A¥¢±Ñ¬° 0¡CGetDC »P ReleaseDC ¥²©w¦¨¹ï¦s¦b¡A²¦³º¥Î§¹¤§«á±oÄÀ©ñ¡A¥H¸`¬ù¨t²Î¸ê·½¡C
·í¨Ï¥ÎªÌ¥H·Æ¹«©ì©Ôµøµ¡Ãä®Ø¡B«ö¤Uµøµ¡¥k¤W¨¤ªº³Ì¤p¤Æ©Î³Ì¤j¤Æ«ö¶s¡B©Î¬Oµøµ¡±qÁôÂÃÅܬ°Åã¥Ü¡K¡Kµ¥¾Þ§@¡A·|¯A¤Î¨ì§ïÅܵøµ¡¤j¤p®É¡AWindows ·|¹ïµøµ¡¨ç¦¡µo¥X WM_SIZE °T®§¡C³o®ÉÔ wParam °Ñ¼Æ¬O¤U±´XÓ¼ÆȤ§¤@¡G
WM_SIZE ªº lParam ¤¤¡A0¡ã15 ¦ì¤¸¬O§ïÅܤj¤p¤§«á¤u§@°Ïªº¼e«×¡A16¡ã31 ¦ì¤¸«h¬O¨ä°ª«×¡C
lstrlen ¥Î¨Ópºâ¦r¦êªºªø«×¡A¨ä쫬¬O¡G
invoke lstrlen,\
lpString ; pointer to a null-terminated string
lpString ¥u¦³¤@ӰѼơAlpString¡A¥Nªí¥H¹s¬°µ²§Àªº¦r¦ê¤§¦ì§}¡C¦pªG lstrlen °õ¦æ¦¨¥\¡A¦^¶ÇȬO¤£§tµ²§Àªº¹s¤§¦r¦êªø«×¡AY¬O ANSI ª©³æ¦ì¬O¦ì¤¸²Õ¡AY¬O¼e¦r¤¸ª©³æ¦ì¬O¦r¤¸¡C¦pªG lpString ©Ò«ü¦ì§}ªº¦r¦ê¬OªÅ¦r¦ê¡]ªÅ¦r¦ê´N¬O¶È¶È¤@Ó NULL ¦r¤¸ºc¦¨ªº¦r¦ê¡^¡A¦^¶ÇȬO¹s¡C
lstrlen ¨ç¦¡ªº¦WºÙ¬Ý°_¨Ó¤£¹³¨ä¥L Win64 API ªº¦WºÙ¨º¼Ë¦³¤j¼g¤Î¤p¼g¡A¤j¼g¥Î©ó°Ï¤À¤@ÓÓ³æ¦r¡Clstrlen ¥þ¬O¤p¼g¡Alstr ¥Nªí long string¡Alen ¥Nªí length¡C³oºØ©R¦W¤èªk¬O¨Ì´` C ¼Ð·Çµ{¦¡®wªº©R¦Wªk¡A¦´Áªº 16 ¦ì¤¸ Windows ¨t²Î¤¤¡A¤Þ¶i¤@³¡¤À³oÃþ¨ç¦¡¡A©Ò¥H lstrlen ¤´¬O¹D¹D¦a¦aªº Win64 API¡C
µL¸¹¼Æ»P¦³¸¹¼Æ¤¤ªº¸¹¡A«üªº¬O¥¿t²Å¸¹¡C¦b¼Æ¾Ç¤W¡A¥¿¼Æ¤£»Ý¯S§Oªí¥Ü¡At¼Æ¥u»Ý¦b¼ÆÈ«e¥[¤Wt¸¹¡A§Y¡u¡Ð¡v¡A´N¥i¥H¤F¡C¨Ò¦p¡u3¡v¬O¥¿¼Æ¡A¡u¡Ð3¡v¬Ot¼Æ¡A¨âªÌ¬Û¥[¬°¹s¡A¥B¨âªÌ»P¹s³£¬Û®t¤T¡A¦b¼Æ½u¤W¨âªÌ»P¹sªº¶ZÂ÷³£¬Û¦P¡A¦ý 3 ¦b¥kÃä¡A¡Ð3 ¦b¥ªÃä¡C¨º»ò¦b¹q¸£ªº°O¾ÐÅ餤¡A¦p¦óªí¥Üt¼Æ©O¡H
¦b¹q¸£¤¤¥H³Ì°ª¦ì¤¸ªí¥Ü²Å¸¹¡A¦pªG³Ì°ª¦ì¤¸¬O¹s¡Aªí¥Ü¥¿¼Æ¡F³Ì°ª¦ì¤¸¬O¤@¡Aªí¥Üt¼Æ¡C³Ì°ª¦ì¤¸¡A¤]¥iºÙ¬°²Å¸¹¦ì¤¸¡]sign bit¡^¡C¥k¹Ï¬O¥H¤@Ӧ줸²Õ¡]¤KӦ줸¡^¬°¨Ò¡A³Ì°ª¦ì¤¸¬O²Ä¤C¦ì¤¸¡A´N¬O²Å¸¹¦ì¤¸¡A¥H¡uS¡vªí¥Ü¡C¦©°£²Å¸¹¦ì¤¸ÁٳѤCӦ줸¡C°²¦p²Å¸¹¦ì¤¸¬O¹s¡A³Ñ¤Uªº¤CӦ줸¯àªí¥Ü 27 ӼơF°²¦p²Å¸¹¦ì¤¸¬O¤@¡A³Ñ¤Uªº¤CӦ줸¤]¯àªí¥Ü 27 Ót¼Æ¡C´«¥y¸Ü»¡¡A¥¿¼Æ©Ît¼ÆªºÓ¼Æ¥»¸Ó¬O¤@¼Ëªº¡C¦ý¬O²Å¸¹¦ì¤¸¬O¹s¡A³Ñ¤Uªº¤CӦ줸¤]§¡¬°¹s¡A¨º»ò³oӼƴN¬O¹s¡F¹s¤£¬O¥¿¼Æ¤]¤£¬Ot¼Æ¡A³o¼Ët¼Æ´N¤ñ¥¿¼Æ¦h¤@Ó¡C
°²¦p§â¤KӦ줸©Ò¯àªí¥Üªº¼Æ¥Ñ¹s¶}©l¡A¤@Ó¤@Ó±µ°_¨Ó¡AÅܦ¨¤U¹Ïªº¶êÀô¡Cº¥ý¬Ý¨ì¹sªº¦ì¸m¡A¹sªº¥kÃä¬O¤@¡B¤G¡B¤T¡K¡K¶¶®É°w¶¤@°é«á¨ì FD¡BFE¡BFF¡A¤S¦^¨ì¹s¡C
¦pªG§â¹s¨âÃ䪺¨â¼Æ¬Û¥[¡A¥ç§Y¡u01¡ÏFF¡v¡A·|±o¨ì¡u100¡v¡A°²¦pµ²ªG¥u¬Ý¤K¦ì¤¸ªºµ²ªG¡A´N¥u¦³¡u00¡v¡A³Ì¥ªÃ䪺¡u1¡v¬O²Ä¤KӦ줸¡A¦p¥k¹Ï¡C¦P²z¡A§â¹s¥ª¥k¨âÃä¬Û¶Z¨â®æªº¡u02¡v»P¡uFE¡v¬Û¥[¡A¥Bµ²ªG¥u¬Ý¤KӦ줸¡A¤]¬O¹s¡C³o¸ò¶ZÂ÷»P¹sµ¥¶ZÂ÷ªº¨â¥¿¼Æ»Pt¼Æ¬Û¥[¡Aµ²ªG¬°¹sªºì²z¤@¼Ë¡C³o¤]´N¬O¬°¤°»ò§â¡uFF¡vq¬°¡u¡Ð1¡v¡B¡uFE¡vq¬°¡u¡Ð2¡v¡K¡K¡C
¥i¯à·|¦³°O¾Ð¸Ì«Ü¦nªºÅªªÌ°Ý¹D¡A²Ä¤@³¹´£¨ì¤G¶i¦ìªº¡u1111 1111¡v¡A¬Û·í©ó¤Q¤»¶i¦ìªº¡uFF¡v¡A¬O¤Q¶i¦ìªº¡u255¡v¡A²{¦b«ç»ò¤SÅܦ¨¤F¡u¡Ð1¡v¤F©O¡Hì¨Ó°O¾ÐÅ餤ªº¼Æȧ¹¥þ¥Ñµ{¦¡¨Ó¸ÑÄÀ¨ì©³¥Nªí¤°»ò¡A©Ò¥H¡uFF¡v¥i¥H¥Nªí¡u255¡v¡A¤]¥i¥H¬O¡u¡Ð1¡v¡C§ó¦³¬ÆªÌ¡A¨Ò¦p¤Q¤»¦ì¤¸ªº¡uA9B1¡v¡A·íµ{¦¡¸ÑÄÀ¬°µL¸¹¼Æ®É¬O¡u43441¡v¡A¸ÑÄÀ¬°¦³¸¹¼Æ®É¬O¡u¡Ð22095¡v¡A¬Æ¦Ü¤]¥i¥H¸ÑÄÀ¬°¸U°ê½Xªº¤å¦r¡A¨º¬O¤ö«z¤å¡uꦱ¡v¡A¦pªG¸ÑÄÀ¦¨ Big5 ½X«h¬O¤¤¤åªº¡u©±¡v¡C
JL »P JLE¡BJG »P JGE ªº»yªk¬O
JL ¼Ð°O ;Y¤p©ó«h¸õÅD JLE ¼Ð°O ;Y¤p©ó©Îµ¥©ó«h¸õÅD JG ¼Ð°O ;Y¤j©ó«h¸õÅD JGE ¼Ð°O ;Y¤j©ó©Îµ¥©ó«h¸õÅD
³o¥|Ó«ü¥O³q±`»P CMP «ü¥O·f°t¡A¥Î¨Ó¤ñ¸û¦³¸¹¼Æªº¤j¤p¡AµM«á¨Ì¾Úµ²ªG¬O§_µo¥Í¸õÅD¡C¥H JL ¬°¨Ò¤l¡A¹³¤U±ªºµ{¦¡¡G
cmp al,22 jl ok
¤ñ¸û AL ¼È¦s¾¹»P±`¼Æ 22¡AY AL ¤p©ó 22¡A¨º»ò´N¸õÅD¦Ü ok ¼Ð°O³B¡Cnª`·Nªº¬O¡AJE/JLE ¬O§_¸õÅD¡A¬On§â AL ·í¦¨¦³¸¹¼Æ¨Ó¤ñ¸û¡C¦pªGn¤ñ¸ûµL¸¹¼Æ¡A¨º»ò¥²¶·¥Î JB¡C¦P¼Ëªº¡AJG »P JGE ¬O±N¨âÓ¹Bºâ¤¸·í°µ¦³¸¹¼Æ¨Ó¤ñ¸û¡AY«eªÌ¸û¤j©Îµ¥©ó¡A¨º»ò¤~µo¥Í¸õÅD¡C
¤U±ªº¨âÓ¨Ò¤l»¡©ú¤F¦³¸¹¼Æ©MµL¸¹¼Æªº¤ñ¸û¡C¥ª¥k¨âÄ椤ªº AL ¼È¦s¾¹¤º¤§È§¡¬°¡uFF¡v¡A¨âÃä³£¬O AL »P 22 ¤ñ¸û¡C¥ý»¡¤ñ¸ûªºµ²ªG¡A¥ªÄæ·|µo¥Í¸õÅD¦Ü¡uok¡v¼Ð°O³B¡A¦Ó¥kÄ椣µo¥Í¸õÅD¡C
mov al,0ffh cmp al,22 j1 ok | mov al,0ffh cmp al,22 jb ok |
ì¦]¬O¥ªÄæ±Ä¥Î¡uJL¡v«ü¥O¡A¥²¶·§â¤ñ¸ûªº¨âÓ¹Bºâ¤¸³£¬Ý¦¨¦³¸¹¼Æ¨Ó¤ñ¸û¡AAL ¤¤ªº¡uFF¡v¬O¡u¡Ð1¡v¡A¤ñ 22 ¤p¡A¬Gµo¥Í¸õÅD¡C¦Ó¥kÄæ±Ä¥Î¡uJB¡v¡A¥²¶·§â¤ñ¸ûªº¨âÓ¹Bºâ¤¸³£¬Ý¦¨µL¸¹¼Æ¡A¡uFF¡vµ¥©ó 255¡A¤ñ 22 ¤j¡A¬G¤£µo¥Í¸õÅD¡C
³Ì«á¾ã²z¦p¤Uªí¡Cªí¤¤ªº¡uG¡v¬O greater ªº·N«ä¡A¡uL¡v¬O less ªº·N«ä¡A¡uA¡v¬O above ªº·N«ä¡A¡uB¡v¬O below ªº·N«ä¡C
¦³¸¹¼Æ | JG¡]Y¤j©ó¡A«h¸õÅD¡^ JGE¡]Y¤j©ó©Îµ¥©ó¡A«h¸õÅD¡^ | JL¡]Y¤p©ó¡A«h¸õÅD¡^ JLE¡]Y¤p©ó©Îµ¥©ó¡A«h¸õÅD¡^ |
µL¸¹¼Æ | JA¡]Y°ª©ó¡A«h¸õÅD¡^ JAE¡]Y°ª©ó©Îµ¥©ó¡A«h¸õÅD¡^ | JB¡]Y§C©ó¡A«h¸õÅD¡^ JBE¡]Y§C©ó©Îµ¥©ó¡A«h¸õÅD¡^ |
x86 «ü¥Oªº MOV «ü¥O¡A¨Ó·½¹Bºâ¤¸»P¥Øªº¹Bºâ¤¸ªºªø«×n¬Û¦P¡A¤]´N¬O»¡§AµLªk§â¤@Ó¦s©ó 16 ¦ì¤¸¼È¦s¾¹¤ºªº¼ÆÈ¡A¥Î MOV «ü¥O²¾¨ì 32 ¦ì¤¸ªºÅܼƤ¤¡A¤Ï¤§¥çµM¡C¦ý¥Î MOVZX »P MOVSX ¥i¥H§âªø«×¸ûµuªº¨Ó·½¹Bºâ¤¸²¾¨ìªø«×¸ûªøªº¥Øªº¹Bºâ¤¸¤¤¡A·íµM³o¨âÓ«ü¥O¤´µMµLªk§âªø«×¸ûªøªº¨Ó·½¹Bºâ¤¸²¾¨ì¸ûµuªº¥Øªº¹Bºâ¤¸¤¤¡A¦]¬°³o¼Ë·|·l¥¢°ª¦ì¤¸¤¤ªº¸ê®Æ¡C
¨Ï¥Î MOVZX ®É·|§âªø«×¸ûµuªº¨Ó·½¹Bºâ¤¸²¾¨ì¸ûªøªº¥Øªº¹Bºâ¤¸¤¤¡A¦Ó¥Øªº¹Bºâ¤¸¦h¥X¨Óªº©Ò¦³¦ì¤¸§¡³]¬°¹s¡AMOVZX ¤¤ªº¡uZ¡v´N¬O zero ªº·N«ä¡C©³¤U¬O MOVZX ªº»yªk¡G
MOVZX r16,r/m8 MOVZX r32,r/m8 MOVZX r64,r/m8 MOVZX r32,r/m16 MOVZX r64,r/m16
MOVZX ªº¥Øªº¹Bºâ¤¸¥i¥H¬O r16¡Br32¡Br64¡A¤À§O¥Nªí 16 ¦ì¤¸¡B32¦ì¤¸¡B64¦ì¤¸ªº¼È¦s¾¹¡C¨Ó·½¹Bºâ¤¸¥i¥H¬O r/m8¡Br/m16¡A¤À§O¬O 8 ¦ì¤¸¡B16 ¦ì¤¸ªº¼È¦s¾¹©Î°O¾ÐÅéÅܼơC¨Ò¦p©³¤Uªº¨Ò¤l¡G
mov eax,11112222H mov cl,88H movzx eax,cl
µ²ªG EAX ¬O 0000 0088H¡AEAX ¤¤¤ñ CL ¦h¥X¨Óªº 24 ¦ì¤¸§¡³]¬°¹s¡C
MOVSX ªº»yªk»P MOVZX ªº»yªk¤@¼Ë¡A©³¤U¬O MOVSX ªº»yªk¡G
MOVSX r16,r/m8 MOVSX r32,r/m8 MOVSX r64,r/m8 MOVSX r32,r/m16 MOVSX r64,r/m16
MOVSX «ü¥O·|§âªø«×¸ûµuªº¨Ó·½¹Bºâ¤¸²¾¨ì¸ûªøªº¥Øªº¹Bºâ¤¸¤¤¡A¦Ó¥Øªº¹Bºâ¤¸¦h¥X¨Óªº©Ò¦³¦ì¤¸§¡³]¬°¨Ó·½¹Bºâ¤¸ªº³Ì°ª¦ì¤¸¡C¹ï¦³¸¹¼Æ¨Ó»¡¡A¨Ó·½¹Bºâ¤¸ªº³Ì°ª¦ì¤¸¡A¨ä¹ê´N¬O²Å¸¹¡CY³Ì°ª¦ì¤¸¬°¹s¡Aªí¥Ü¥¿¼Æ¡F¬°¤@¡Aªí¥Üt¼Æ¡C¤£½×¬O¥¿¼ÆÁÙ¬Ot¼Æ¡A¸g¹L MOVSX ²¾°Ê¸ê®Æ¨ì¥Øªº¹Bºâ¤¸¤§«á¡A¨äȤ´µM¬Û¦P¡A¦ý¦ì¤¸¼ÆÅܦh¤F¡A¯à°÷¹Bºâªº½d³ò¤]Åܤj¡C¨Ò¦p©³¤Uªº¨Ò¤l¡G
mov eax,11112222H mov cl,88H movsx eax,cl
EAX ³Ì«á·|Åܦ¨ 0FFFF FF88H¡CCL ªº³Ì°ª¦ì¤¸¬°¡u1¡v¡A¦]¦¹°õ¦æ MOVSX ¤§«á¡AEAX ¤ñ CL ¦h¥X¨Óªº³¡¤À¥þ³]¬°¡u1¡v¡C
nÁA¸Ñ TEST «ü¥O¡AÀ³¥ý»¡©ú AND «ü¥O¡A¦]¬°¥¦Ì´X¥G¤@¼Ò¤@¼Ë¡CAND «ü¥Oªº»yªk¬O
AND ¥Øªº¹Bºâ¤¸,¨Ó·½¹Bºâ¤¸
³oÓ«ü¥O¬O±N¥Øªº¹Bºâ¤¸»P¨Ó·½¹Bºâ¤¸°µ AND ¹Bºâ¡A¦A±Nµ²ªG¦s¤J¥Øªº¹Bºâ¤¸¡CAND ½Ķ¦¨¡u¥B¡vªº·N«ä¡A³oºØ¹Bºâ¬O¥u¦³·í¨âÓ±ø¥ó³£¦¨¥ß®É¤~¬°¯u¡C
¨Ò¦p§A©ñ¾Ç¦^®a¡A¶ý¶ý»¡¡G¡un¼g§¹¤µ¤Ñªº§@·~¨Ã¥B¹w²ß§¹©ú¤éªº¥\½Ò¤~¯àª±¹q¸£¡C¡v·N«ä´N¬O¦pªG§A¡u¤µ¤é§@·~¡v©M¡u¹w²ß©ú¤é¥\½Ò¡v¥un¦³¤@¶µ¨S°µ§¹¡A´N¤£¯à¡uª±¹q¸£¡v¡A¥u¦³·í¨â¶µ³£°µ¦n¤F¤~¥i¥Hª±¹q¸£¡C
¦b¹q¸£¤¤¡A¡u1¡vªí¥Ü¯u©Î¦¨¥ßªº·N«ä¡A¡u0¡vªí¥Ü°°©Î¤£¦¨¥ßªº·N«ä¡C©Ò¥H¡A¥u¦³·í¨âӼƳ£¬°¤@¡A°µ AND ¹Bºâ®É¡A¨äµ²ªG¤~¬°¤@¡A¥un¹Bºâªº¨â¼Æ¦³¤@Ó¬°¹s¡Aµ²ªG´N¬°¹s¡CAND ¹Bºâªº¯uȪí¦p¤U¡G
0 AND 0¡×0 0 AND 1¡×0 1 AND 0¡×0 1 AND 1¡×1
AND «ü¥O¤¤ªº¥Øªº¹Bºâ¤¸¥i¥H¬O¼È¦s¾¹©Î°O¾ÐÅéÅܼơA¨Ó·½¹Bºâ¤¸¥i¥H¬O±`¼Æ¡B¼È¦s¾¹©Î°O¾ÐÅéÅܼơA¦ý¬O¨Ó·½¹Bºâ¤¸»P¥Øªº¹Bºâ¤¸¤£¥i¦P¬°°O¾ÐÅéÅܼơC¨Ó·½¹Bºâ¤¸»P¥Øªº¹Bºâ¤¸ªºªø«×¥²¶·¤@P¡A°µ AND ¹Bºâ®É¡A¬Û¹ïÀ³ªº¦ì¤¸¤¬¬Û¹Bºâ¡A¥ç§Y¨Ó·½¹Bºâ¤¸ªº²Ä 0 ¦ì¤¸»P¥Øªº¹Bºâ¤¸²Ä 0 ¦ì¤¸°µ AND ¹Bºâ¡B¨Ó·½¹Bºâ¤¸ªº²Ä 1 ¦ì¤¸»P¥Øªº¹Bºâ¤¸²Ä 1 ¦ì¤¸°µ AND ¹Bºâ¡K¡K¨ä¾l¨Ì¦¹Ãþ±À¡C
°µ§¹¡u¥B¡v¹Bºâ¤§«á¡ACPU ·|²M°£¶i¦ìºX¼Ð»P·¸¦ìºX¼Ð¡A¨Ã®Ú¾Ú¹Bºâµ²ªG§ïÅܲŸ¹ºX¼Ð»P¹sȺX¼Ð¡A¦Ó»²§UºX¼Ð¤§ÈµL·N¸q¡C
Á|Ó¨Ò¤l»¡©ú¡C¦p¥k¹Ïªº DL ¼È¦s¾¹¤§È¬° 24H¡A°õ¦æ¡uAND DL,0FH¡v®É¡A§â¨CӦ줸¹ï»ô«á¡A¨CӦ줸°µ AND ¹Bºâ«á¡Aµ²ªG¦p³Ì¤U±¶À¦r©Ò¥Ü¡C¦]¬°³Ì«áµ²ªG¤£¬O¹s¡A¬G CPU ·|²M°£¹sȺX¼Ð¡F³Ì«áµ²ªGªº³Ì°ª¦ì¬O¹s¡A¬G CPU ·|²M°£²Å¸¹ºX¼Ð¡C
ȱo¤@´£ªº¬O¡A0FH ³oÓ¼ÆÈ¡A¸û°ªªº¥|Ӧ줸§¡¬° 0¡A¦]¦¹¤£ºÞ DL ¸û°ªªº¥|Ӧ줸¬O¤°»ò¡A»P¨ä°µ AND ¹Bºâ«á§¡¬° 0¡F¦Ó¸û§Cªº¥|Ӧ줸§¡¬°¤@¡A¤]¤£ºÞ DL ¸û§Cªº¥|Ӧ줸¬O¤°»ò¡A¨ä¼ÆÈ«O«ù¤£ÅÜ¡C¹³¤W±³o¼Ë¡A§â¤@Ó¾ã¼Æªº¬Y¨Ç¦ì¤¸²M°£ ( ²M°£ªº·N«ä¬OÅܬ° 0 )¡A¦Ó«O¯d¨ä¥L¦ì¤¸ªº¹Lµ{ºÙ¬°¡u¾B¸n¡v( mask )¡A¤èªk«Ü²³æ¡A¥ý³]©w¤@¼ÆÅýn¾B¸nªº¦ì¤¸³£³]¬°¹s¡AµM«á©Mì¾ã¼Æ°µ AND ¹Bºâ´N¥i¥H¤F¡C
TEST «ü¥Oªº»yªk¬O¡G
TEST ¥Øªº¹Bºâ¤¸,¨Ó·½¹Bºâ¤¸
TEST «ü¥O·|¨Ï¥Øªº¹Bºâ¤¸»P¨Ó·½¹Bºâ¤¸°µ¡u¥B¡v¹Bºâ¡AµM«á²M°£¶i¦ìºX¼Ð»P·¸¦ìºX¼Ð¡A¨Ã¨Ì¾Úµ²ªG§ïÅܲŸ¹ºX¼Ð»P¹sȺX¼Ð¡A¦Ó»²§UºX¼Ð¤§ÈµL·N¸q¡F¦ý¬O¡ATEST ¨Ã¤£·|±N¹Bºâµ²ªG¼g¤J¥Øªº¹Bºâ¤¸¤º¡A³o¬O»P AND «ü¥O¤£¦Pªº¦a¤è¡C¥i¯à·|¦³¤H²£¥ÍºÃ°Ý¡A¦pªG¤£«O¦s¹Bºâµ²ªG¡A¨º»ò¡ATEST «ü¥O¦³¬Æ»ò¥Î©O¡H©³¤UÁ|¨âÓ¨Ò¤l¡G①ÀËÅç¤@¼Æ¬O¥¿¼ÆÁÙ¬Ot¼Æ ( ¨£ DOS ²Õ¦X»y¨¥²Ä¤Q¥|³¹ )¡B②ÀËÅç¤@¼Æ¬O©_¼ÆÁÙ¬O°¸¼Æ¡C
¦]¬°¤@¼Æªº³Ì¥kÃ䨺¦ì¼Æ¨M©w¤F¦¹¼Æ¬O©_¼ÆÁÙ¬O°¸¼Æ ( ¨£²Ä¤@³¹µù¤T )¡A¤£½×¬O¥H¤G¶i¦ì¡B¤Q¶i¦ì©Î¤Q¤»¶i¦ìªí¥Ü¡A³£¬O¤@¼Ë¡C¥i¥H¥H TEST «ü¥O¹F¨ì¥Øªº¡C¨Ò¦pnÀËÅç AL ¼È¦s¾¹¤§È¬O©_¼ÆÁÙ¬O°¸¼Æ¡A¥i¥H¥Î©³¤Uªºµ{¦¡¡G
test al,1 jz even odd: ⁝ ;AL¬°©_¼Æ ⁝ even: ⁝ ;AL¬°°¸¼Æ
³o¤»Ó x86 «ü¥O³£¬O±Nì¨Ó¥e¥Î¸û¤Ö¦ì¤¸ªº¸ê®ÆÂX¥R¦¨¸û¦h¦ì¤¸ªº¸ê®Æ¡A¤]¥i¥H§â¥¦Ìµø¬°¯à§ïÅܸê®ÆÃþ«¬ªº«ü¥O¡C¦]¬°§@¥ÎÃþ¦ü¡A©Ò¥H¦b³o¸Ì¤@¨Ö¤¶²Ð¡A³o¤»Ó«ü¥O¥i¤À¬°¨âÃþ¡G①CBW¡BCWDE¡BCDQE »P ②CWD¡BCDQ¡BCQO¡C¥ý»¡ CBW «ü¥O¡C
CBW «ü¥O¬O¡uconvert byte to word¡vªº·N«ä¡A·N§Y±N¦ì¤¸²Õªº¼ÆÈÅܦ¨¦r²Õ¡A¨ä»yªk¬O
CBW
ªí±¤W CBW ¨S¦³¹Bºâ¤¸¡A¦ý¨ä¹ê¬O¦³ÓÁôÂ꺹Bºâ¤¸¡A¨º´N¬O AX ¼È¦s¾¹¡CCBW ·|§â¦s©ó AL ªº¼ÆÈ¡AÅܦ¨¦s©ó AX¡C¤èªk¬O§â AL ªº²Å¸¹¦ì¤¸½Æ»s¨ì AX ªº²Ä 8¡ã15 ¦ì¤¸¤§¤¤¡C¦b¤G¶i¦ì¼ÆȤ¤¡A³Ì°ª¦ì¤¸¬O²Å¸¹¦ì¤¸¡AY³Ì°ª¦ì¤¸¬° 1¡Aªí¥Üt¼Æ¡FY³Ì°ª¦ì¤¸¬° 0¡Aªí¥Ü¥¿¼Æ¡C
Y AL ªº²Ä 7 ¦ì¤¸¬° 0¡A°õ¦æ§¹ CBW «á¡AAH ¤º©Ò¦³¦ì¤¸³£Åܬ° 0¡FY AL ªº²Ä 7 ¦ì¤¸¬° 1¡A°õ¦æ§¹«á¡AAH ¤º©Ò¦³¦ì¤¸Åܬ° 1¡C¤]´N¬O»¡¡ACBW ·|§â AL ¤ºªº²Å¸¹¡A©µ¦ù¨ì AH ¤º¡C³o¼Ë´N¯à§â AL ¤¤ªº¦³¸¹¼Æ¡AÂX¥R¦Ü AX¡C
¨Ò¦p¤U¹Ï AX ¬° 0FF65H¡AAL ¬° 65H¡A²Ä¤C¦ì¤¸¬O¹s¡C·í°õ¦æ CBW «á¡AAL ¤Wªº²Ä¤C¦ì¤¸ÂX¥R¨ì AH ¼È¦s¾¹¡A¨Ï AH ¤Wªº¨CӦ줸³£Åܦ¨ 0¡C
CWDE «ü¥O¬O¡uconvert word to doubleword¡vªº·N«ä¡A§â AX ªº²Ä 15 ¦ì¤¸½Æ»s¨ì EAX ªº²Ä 16¡ã31 ¦ì¤¸¡CCDQE «ü¥O¡uconvert doubleword to quadword¡vªº·N«ä¡A¥¦§â EAX ªº²Ä 31 ¦ì¤¸½Æ»s¨ì RAX ªº²Ä 32¡ã63 ¦ì¤¸¡C
CWD «ü¥OÁöµM¤]¬O¡uconvert word to doubleword¡v¡A¦ý«o¬O§â AX ªº²Ä 15 ¦ì¤¸½Æ»s¨ì DX ªº©Ò¦³¦ì¤¸¤º¡C¦P¼Ë¡ACDQ ¬O§â EAX ªº²Ä 31 ¦ì¤¸½Æ»s¨ì EDX ªº©Ò¦³¦ì¤¸¤º¡FCQO ¬O§â RAX ªº²Ä 63 ¦ì¤¸½Æ»s¨ì RDX ªº©Ò¦³¦ì¤¸¤º¡C
³Ì«á¾ã²z¦¨¤Uªí¡G
¥Î³~ | «ü¥O | »¡©ú | «ü¥O | »¡©ú |
¦ì¤¸²ÕÅܦr²Õ | CBW | AL ªº²Å¸¹¦ì¤¸¡÷AX | ||
¦r²ÕÅÜÂù¦r²Õ | CWDE | AX ªº²Å¸¹¦ì¤¸¡÷EAX | CWD | AX ªº²Å¸¹¦ì¤¸¡÷DX:AX |
Âù¦r²ÕÅÜ¥|¦r²Õ | CDQE | EAX ªº²Å¸¹¦ì¤¸¡÷RAX | CDQ | EAX ªº²Å¸¹¦ì¤¸¡÷EDX:EAX |
¥|¦r²ÕÅܤK¦r²Õ | CQO | RAX ªº²Å¸¹¦ì¤¸¡÷RDX:RAX |
°}¦C ( array ) ¬O³\¦h¸ê®ÆÃþ«¬¬Û¦Pªº¸ê®Æ¶°¦X¦b¤@°_©Ò§Î¦¨ªº¤@ºØ¸ê®Æµ²ºc¡C¦b²Õ¦X»y¨¥ùØ¡A¥i¥H¥Î¥ô¦ó¤wª¾ªº¸ê®ÆÃþ«¬©Î¬O¦Û¦æ«Å§iªºµ²ºcÅé©w¸q¤@Ó°}¦C¡A¦b°}¦C¤¤ªº¨C¤@µ§¸ê®Æ³£ºÙ¬°¤¸¯À ( element )¡A¨CÓ¤¸¯À³£¥H¡u,¡v¤À¹j¡C¦pªG¤¸¯À¤Ó¦h¡A¤@¦æ¼g¤£¤U¡A¥i¥H¦b¤@¦æ³Ì«á¤@Ó¤¸¯À¤§«á¥[¤W¡u,¡v¡AµM«á´«¦æ¡C¨Ò¦p©w¸q¤@Ó 10 ¥H¤U½è¼Æ©Ò§Î¦¨ªº prime1 °}¦C¡A¦p¤U¡G
prime1 DB 2,3,5,7 prime2 DB 2,3,5,7,11,13,17,19,23,29,31, 37,41,43,47 love DB "I love my wife so much!"
prime2 ¤]¬O¤@Ó°}¦C¡A¥Ñ 15 Ó¤¸¯À²Õ¦¨¡A¨CÓ¤¸¯Àªº¸ê®ÆÃþ«¬³£¬O BYTE¡A¦Ó¥B¦³´«¦æ¡C³Ì«á¤@Ó¨Ò¤l¡AÁöµM love ¬O¤@Ó¦r¦ê¡A¦ý¬O¥¦¤]²Å¦X¥Ñ³\¦h¸ê®ÆÃþ«¬¬Û¦Pªº¸ê®Æ§Î¦¨ªº¶°¦X¡A¦¹¦r¦ê¤]¥i¥H¬Ý¦¨¬O°}¦C¡C¹³ love ´N¬O¥Ñ 23 Ó¤¸¯À¡A¨CÓ¤¸¯À³£¬O¤@Ӧ줸²Õ§Î¦¨ªº°}¦C¡C
¦A¦^¨ì SYSMTR1 µ{¦¡¡AnÅã¥Ü GetSystemMetrics ªº°Ñ¼Æ¡AnIndex¡A¦³ 95 ºØ¥i¥Îªº¤£¦P¼ÆÈ¡A¦U¥Hªøµu¤£¤@ªº¦WºÙªí¥Ü¡F¥t¥~¡A³o 95 ºØ¼ÆȪº»¡©ú¡Aªø«×¤]¤£¦P¡Aµø¬°¦³ 95 µ§¸ê®Æ¡Cn¦s¨ú¬Y¤@µ§¸ê®Æ¡A¨Ã¤£®e©ö¡C¦¹³B¡A¤p¤ì°¸¥H¨C¤@µ§¸ê®Æªº°_©l¦ì§}¶°¦X°_¨Ó¡A§Î¦¨¤@Ó¦³ 95 Ó¤¸¯À¡A¦W¬°¡uaryPt¡vªº°}¦C ( ary ¬O array ¤§·N¡APt ¬O«ü¼Ð¡Apointer ªº·N«ä )¡C¹³©³¤Uªº¼Ë¤l¡G
aryPt DQ n00,n01,n02,n03,n04¡K¡Kn94
¦b 64 ¦ì¤¸ªº§@·~¨t²Î¤¤¡A¦ì§}¤]¬O¥H 64 ¦ì¤¸ªí¥Ü¡A64 ¦ì¤¸¬Û·í©ó¥|¦r²Õ ( quard word )¡A¦]¦¹¤W¦¡¥H¡uDQ¡v©w¸q¦¹°}¦C¡C¥k¹Ï¬O aryPt °}¦C¦b°O¾ÐÅ餤ªº±¡§Î¡C¨CÓ¶À¦â®Ø¥Nªí¤@Ó¥|¦r²Õªøªº°O¾ÐÅé¡A¦s©ñµÛ¨C¤@µ§¸ê®Æªº¦ì§}¡A¥Ñ²Ä¹sµ§¸ê®Æªº¦ì§}¶}©lª½¨ì²Ä 94 µ§¡A¤]¥i¥H§â¨CÓ¶À¦â®Ø¬Ý¦¨¦s©ñµÛ¤@Ó¤¸¯À¡C¥|¦r²Õ¨ä¹ê´N¬O¤KӦ줸²Õ¡A©Ò¥H¨CӮخؤS¦A¤À¦¨¤Kµ¥¤À¡A¥i¥Ñ®Ø®Ø¤U½t¬Ý¨ì¡C
¦b¨CÓ¶À¦â®Ø®Ø¤U¤è¡A¦³¿j¬õ¦âªº½bÀY«üµÛ¨CÓ¤¸¯Àªº°_©l¦ì§}¡C°²³]²Ä¹sÓ¤¸¯Àªº°_©l¦ì§}¬O x¡A¨º»ò²Ä¤@Ó¤¸¯Àªº°_©l¦ì§}´N¬O x¡Ï8¡A²Ä¤GÓ¤¸¯Àªº°_©l¦ì§}´N¬O x¡Ï16¡K¡K¡C¦]¦¹n¨ú±o²Ä n Ó¤¸¯À ( n ¥Ñ¹s¶}©l ) ªº¦ì§}¨Ã¤£Ãø¡A´N¥u»Ýnpºâ 8¡Ñn ¦A¥[¤W aryPt °_©l¦ì§}§Y¥i¡A¦p¤U±ªºµ{¦¡¡G
xor r10,r10 ;¨ÏR10Åܬ°0 lea r9,aryPt ;¨ÏR9Åܬ°aryPtªº°_©l¦ì§} mov r10d,n shl r10,3 ;R10¡×8¡Ñn add r9,r10 ;R9¡×aryPt°}¦C¤¤¡A²Änªº¤¸¯Àªº¦ì§}
°õ¦æ¹L¤W±µ{¦¡¤§«á¡AR9 ¼È¦s¾¹¤§¼ÆÈ¡A´N¬O²Ä n Ó¤¸¯Àªº¦ì§}¡C¦¹¦ì§}¤W´N¦s¦³²Ä n µ§¸ê®Æªº°_©l¦ì§}¡C±N³o²Ä n µ§¸ê®Æªº°_©l¦ì§}Ū¨ú¥X¨Ó ( ³oºØŪ¨ú°O¾ÐÅé¸ê®Æªº¤è¦¡ºÙ¬°¶¡±µ©w§} ) ¤§«á¡A´N¥i¥H¦s¨ú²Ä n µ§¸ê®Æªº°Ñ¼ÆÈ¡B°Ñ¼Æ¦WºÙ¤Î°Ñ¼Æ¤§»¡©ú¡Cµ{¦¡½X¦p¤U¡G
mov r11,[r9] ;R11¡×²Ä n µ§¸ê®Æªº°_©l¦ì§}
movzx r10,WORD PTR [r11]
R11 ¼È¦s¾¹´N¬O²Ä n µ§¸ê®Æªº°_©l¦ì§}¡A¥i¥H¥Î R11 ¥h¦s¨ú³oµ§¸ê®Æªº°Ñ¼ÆÈ¡B°Ñ¼Æ¦WºÙ¡C¹³¤W±ªº R10 ´N¬O²Ä n µ§¸ê®Æªº°Ñ¼ÆÈ¡C°²¦p³o¼ËÁÙ«ÜÃøÁA¸Ñ¡A¨º»ò¥i¥H¥Î x64dbg ¸ü¤J SYSMTR1.EXE¡A¦b³B²z WM_PAINT °T®§ªºµ{¦¡¤¤¡A¦³¤@¹D¡ulea r9,aryPt¡v«ü¥O¡A¦b¦¹³B³]¸m¤¤Â_ÂI¡A´N¯à±o¨ì aryPt °}¦Cªº°_©l¦ì§}¡A¨ÃÆ[¹î¤§¡C
¥H x64dbg Æ[¹î aryPt °}¦C¡A°²³]¥¦¦b°O¾ÐÅé¦ì§} 7FF606173263 ³B¡A¤]¬O²Ä¹sÓ¤¸¯Àªº¦ì§} ( ¤U±¸ê®Æªº¥Õ¦â³¡¤À )¡F¬õ¦â³¡¤À«h¬O²Ä¤GÓ¤¸¯Àªº¦ì§}¡C¦pªG§Aªº aryPt °}¦Cªº°_©l¦ì§}»P«e±¤£¦P¡A¨º¬O«Ü¥¿±`ªº¡C¦]¬°§@·~¨t²ÎÁ`¬O§ä¨ì¦³¨¬°÷ªº°O¾ÐÅé¥i¥Î¡A´N·|±Nµ{¦¡¸ü¤J¦Ü¸Ó°O¾ÐÅ餺¡A¦Ó¦b¦¹¤§«e¡A°õ¦æ¦h¤Öµ{¦¡¥H¤Î¦UÓµ{¦¡©Ò®ø¯Óªº°O¾ÐÅé³£·|¼vÅT¨Ï¥Î°O¾ÐÅ骺¦h¹è¡A©Ò¥H aryPt °}¦Cªº°_©l¦ì§}À³¸Ó·|»P¤U±ªº¤£¦P¡C
00007FF606173260 65 72 00 F0 20 17 06 F6 7F 00 00 14 21 17 06 F6 er.ð ..ö....!..ö 00007FF606173270 7F 00 00 39 21 17 06 F6 7F 00 00 62 21 17 06 F6 ...9!..ö...b!..ö 00007FF606173280 7F 00 00 8E 21 17 06 F6 7F 00 00 B1 21 17 06 F6 ....!..ö...±!..ö
¦A¨Ì¾Ú aryPt ªº°_©l¦ì§}¡A7FF6061720F0 ( ¥Õ¦â³¡¤À )¡A¥i¥H¥Î x64dbg Æ[¹î¸Ó¦ì§}ªº¤º®e¦p¤U ( ²HÂŦ⪺¬O²Ä¤Gµ§¸ê®Æ )¡G
00007FF6061720F0 00 00 53 4D 5F 43 58 53 43 52 45 45 4E 00 50 72 ..SM_CXSCREEN.Pr
00007FF606172100 69 6D 61 72 79 20 64 69 73 70 6C 61 79 20 77 69 imary display wi
00007FF606172110 64 74 68 00 01 00 53 4D 5F 43 59 53 43 52 45 45 dth...SM_CYSCREE
00007FF606172120 4E 00 50 72 69 6D 61 72 79 20 64 69 73 70 6C 61 N.Primary displa
00007FF606172130 79 20 68 65 69 67 68 74 00 02 00 53 4D 5F 43 58 y height...SM_CX
00007FF606172140 56 53 43 52 4F 4C 4C 00 56 65 72 74 69 63 61 6C VSCROLL.Vertical
00007FF606172150 20 73 63 72 6F 6C 6C 20 62 61 72 20 77 69 64 74 scroll bar widt
°²³]²{¦bµ{¦¡n¦L¥X²Ä¤Gµ§¸ê®Æ¡A¤]´N¬On¦L¥X¡uSM_CXVSCROLL 2 Vertical scroll bar width¡K¡K¡v¡A¨º»òº¥ýnpºâ aryPt ¤¤²Ä¤GÓ¤¸¯À¦ì§}¡Apºâ¦¹¦ì§}ªºµ{¦¡½X¦p¤U¡G
xor r10,r10 ;¨ÏR10Åܬ°0 lea r9,aryPt ;¨ÏR9Åܬ°aryPtªº°_©l¦ì§}¡AR9¡×7FF606173263 mov r10d,i ;R10¡×2¡A²Ä2Ó¤¸¯À shl r10,3 ;R10¡×16D¡×10H¡A¨£²Ä¤G³¹SHL«ü¥O add r9,r10 ;R9¡×aryPt°}¦C²Ä2Ó¤¸¯Àªº¦ì§}¡×7FF606173273
²Ä¤G¨B¡A¸g¹L¤Wzµ{¦¡¡AR9 ¤º´N¬O²Ä¤GÓ¤¸¯Àªº¦ì§}¡AŪ¨ú¦¹¦ì§}¤¤ªº¼ÆÈ¡A¸Ó¼ÆÈ´N¬O²Ä¤Gµ§¸ê®Æªº°_©l¦ì§}¡Cµ{¦¡½X¦p¤U¡G
mov r11,[r9] ;¨ìR9©Ò«ü¦ì§}7FF606173273¡AŪ¨ú¸Ó¦ì§}¤§È¡A¦s¤JR11¡AR11¡×7FF606172139
²Ä¤T¨B¡A¨Ì¾Ú²Ä¤Gµ§¸ê®Æªº°_©l¦ì§}¡A¥i¥HŪ¨ú GetSystemMetrics ªº°Ñ¼ÆÈ¡B°Ñ¼Æ¦WºÙ¡B°Ñ¼Æ»¡©úµ¥¸ê®Æ¡Aµ{¦¡½X¦p¤U¡G
movzx r10,WORD PTR [r11] ;¨ìR11©Ò«ü¦ì§}7FF606172139¡AŪ¨ú¸Ó¦ì§}¤@Ó¦r²Õ¤§È¡AR10¡×0002 mov nIndex,r10d add r11,2 mov pt1,r11 ;pt1¡×R11¡×nIndex¦WºÙ¦ì§}¡×7FF60617213B invoke lstrlen,r11 mov len1,rax ;len1¡×nIndex¦WºÙªø«×¡×0C inc rax add rax,pt1 mov pt2,rax ;pt2¡×RAX¡×nIndexªº»¡©ú¦r¦ê¡×7FF606172148
¡u.if/.elseif/.else/.endif¡v¥¨¶°¬O½Ñ¦ì¥ý¶i©Ò¼¶¼gªº¡A«D ML64 ªº«O¯d¦r¡A¬G¦³°Ï¤À¤j¤p¼g ( ¥ç§Y³£¥²¶··Ó©³¤Uªº¤j¤p¼g¨Ó¼g¡A§_«h·|µo¥Í¿ù»~ )¡C¥¦ªº»yªk¦³¤TºØ¡A¥ý»¡³Ì²³æªº¤@ºØ¡G
.if §PÂ_¦¡ µ{¦¡¤ù¬q .endif
¤W±³o¬qµ{¦¡½X¬O»¡¡A·í§PÂ_¦¡¬°¯u®É¡A°õ¦æµ{¦¡¤ù¬q¤ºªºµ{¦¡½X¡FY§PÂ_¦¡¬°°²¡A«h¸õ¦Ü .endif ¤§«áªºµ{¦¡½X°õ¦æ¡A¦Ó¤£°õ¦æµ{¦¡¤ù¬q¤ºªºµ{¦¡½X¡C§PÂ_¦¡ªº¼gªk¡A¸ò¡u.while/.break .if/.endw¡v¥¨¶°ªº§PÂ_¦¡¬Û¦P¡A½Ð°Ñ¾\²Ä¤C³¹¡C
²Ä¤GºØ»yªk¬O¡G
.if §PÂ_¦¡ µ{¦¡¤ù¬q¤@ .else µ{¦¡¤ù¬q¤G .endif
¤W±ªºµ{¦¡½X¬O»¡¡A·í§PÂ_¦¡¬°¯u®É¡A°õ¦æµ{¦¡¤ù¬q¤@¸Ì±ªºµ{¦¡½X¡A«Ý°õ¦æ§¹«á¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡FY§PÂ_¦¡¬°°²¡A«h°õ¦æµ{¦¡¤ù¬q¤G¸Ì±ªºµ{¦¡½X¡A°õ¦æ§¹¤§«á¤]¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡C
²Ä¤TºØ»yªk¸û¬°½ÆÂø¡G
.if §PÂ_¦¡¤@ µ{¦¡¤ù¬q¤@ .elseif §PÂ_¦¡¤G µ{¦¡¤ù¬q¤G .elseif §PÂ_¦¡¤T µ{¦¡¤ù¬q¤T ⁝ .else µ{¦¡¤ù¬q .endif
¤W±ªºµ{¦¡½X¬O»¡¡A·í§PÂ_¦¡¤@¬°¯u®É¡A°õ¦æµ{¦¡¤ù¬q¤@¸Ì±ªºµ{¦¡½X¡A«Ý°õ¦æ§¹«á¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡FY§PÂ_¦¡¤@¬°°²¡A¥B§PÂ_¦¡¤G¬°¯u¡A«h°õ¦æµ{¦¡¤ù¬q¤G¸Ì±ªºµ{¦¡½X¡A°õ¦æ§¹¤§«á¤]¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡FY§PÂ_¦¡¤@»P§PÂ_¦¡¤G§¡¬°°²¡A¥B§PÂ_¦¡¤T¬°¯u¡A«h°õ¦æµ{¦¡¤ù¬q¤T¸Ì±ªºµ{¦¡½X¡A°õ¦æ§¹¤§«á¤]¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡K¡K¡FY¥H¤W§PÂ_¦¡§¡¬°°²¡A´N°õ¦æµ{¦¡¤ù¬q¤ºªºµ{¦¡½X¡A°õ¦æ§¹¤§«á¤]¸õ¦Ü .endif ¤§«áªºµ{¦¡½XÄ~Äò°õ¦æ¡C.else »Pµ{¦¡¤ù¬q¥i¥H¬Ù²¤¡A¦pªG¬Ù²¤¡A¨º»ò©Ò¦³§PÂ_¦¡¬°°²®É¡A´N¤£·|°õ¦æ .if ¨ì .endif ¤§¶¡ªº¥ô¦óµ{¦¡¤ù¬q¡A¦Ó¬Oª½±µ¸õ¦Ü .endif ¤§«áªºµ{¦¡°õ¦æ¡C
SYSMTR1.ASM »P SYSMTR.INC Àɮצ³ÂI¨à¤j¡A±N¨äÀ£ÁY¦¨ SYSMTR1.RAR¡AÀx¦s©ó MEGA ¶³ºÝ¸Ì¡C³o¸Ì¡A¤p¤ì°¸¤£¥´ºâ±N SYSMTR1.ASM §¹¾ã¦C¥X¨Ó¨Ã¸Ñ»¡¡A¦]¬°½g´T¤Ó¤j¡C¦Ó¥B«e±»¡¹L¡AWindows µ{¦¡¦bµù¥Uµøµ¡Ãþ§O¡B«Ø¥ßµøµ¡¡B°T®§°j°éµ¥ì²z³£¤@¼Ë¡A¥Î¤£µÛ¸ÑÄÀ¡C³Ì»Ýn¸Ñ»¡ªº¬O³B²z WM_CREATE¡BWM_SIZE¡BWM_VSCROLL¡BWM_PAINT ¥|«h°T®§ªº¹Lµ{¡C
SYSMTR1.ASM ¦b³B²z WM_CREATE °T®§®É¡A©I¥s GetTextMetrics ¥HÀò¨ú¦r¤¸ªº¬ÛÃö¸ê®Æ¡C¤£¹L GetTextMetrics ªº²Ä¤@ӰѼƴN¬O¸Ë¸m¤º®e¥N½X¡An¦b³B²z WM_CREATE °T®§ªº¹Lµ{¤¤Àò±o¸Ë¸m¤º®e¥N½X¡A¤£¯à©I¥s BeginPaint¡A¥²¶·©I¥s GetDC¡A¨Ã¥B¦b¨Ï¥Î§¹¸Ë¸m¥N½X¤§«á¡A©I¥s ReleaseDC ¥HÄÀ©ñ¸ê·½¡C
©I¥s GetTextMetrics ±o¨ì¦r¤¸¬ÛÃö¸ê®Æ«á¡A´N¥i§Q¥Î³o¨Ç¸ê®Æ¥hpºâ¤TÓ«nªº¶q¡G①¤@¦Cªº°ª«×¡A¦s©ó cyChar ÅܼƤ¤¡C②¥§¡¦r¤¸ªº¼e«×¡A¦s©ó cxChar ÅܼƤ¤¡C③¤j¼g¦r¥Àªº¥§¡¼e«×¡A¦s©ó cxCaps ÅܼƤ¤¡C
¦A®Ú¾Ú¥§¡¦r¤¸ªº¼e«×¡B¤j¼g¦r¥Àªº¥§¡¼e«×¡A¥hpºâ x1¡Bx2¡Bx3 ¤TÓ±`¼Æ¡Cx1 ¬O²Ä¤GÄæ¥k½tªº X ®y¼Ð¡Ax2 ¬O²Ä¤TÄ楪½tªº X ®y¼Ð¡Ax3 ¬O²Ä¥|Äæ¥k½tªº X ®y¼Ð¡A¤]¬O¥|ÓÄæ¦ìªºÁ`¼e«×¡C¦b³B²z WM_PAINT °T®§®É¡Aø»s¥Ñ GetSystemMetrics ±o¨ìªº¸ê®Æ®É¡A·|¥Î±oµÛ³o¤TÓ±`¼Æ¡A©Ò¥H¨Æ¥ý¥ýpºâ¦n¡A«O¦s¦b³o¨Ç±`¼Æ¸Ì¡C¤U¹Ï»¡©ú³o¤TÓ±`¼Æ¡C¥Ñ¹Ï¤¤¥i¥Hª¾¹D¡A²Ä¤@Äæ¹ï»ô¥ªÃä¡AX ®y¼Ð§¡¬° 0¡AY ®y¼Ð¨C©¹¤U¤@¦C«K¼W¥[ cyChar ( ²HÂŦ⪺¤TÓ®y¼Ð )¡C²Ä¤GÄæ¿é¥Xªº¬O¼ÆÈ¡A¬G¹ï»ô¥kÃä¡AX ®y¼Ð§¡¬Û¦P ( ´N¬O x1 )¡AY ®y¼Ð¤]¬O¨C©¹¤U¤@¦C«K¼W¥[ cyChar ( ¾í¦âªº¤TÓ®y¼Ð )¡C²Ä¤TÄæ¬O GetSystemMetrics °Ñ¼Æªº»¡©ú¡A¹ï»ô¥ªÃä¡A¨ä¥ª½tªº X ®y¼Ð§¡¬° x2¡AY ®y¼Ð¤]¬O¨C©¹¤U¤@¦C«K¼W¥[ cyChar ( ¶À¦âªº®y¼Ð )¡C
x1 ¤§Èµ¥©ó MAXCHR_IDX¡ÑcxCaps+6¡ÑcxChar¡A³o¬O¦]¬° GetSystemMetrics ªº°Ñ¼Æ¦W§¡¬°¤j¼g¦r¥À¡A¬G¥Î¤j¼g¦r¥Àªº¥§¡¼e«× ( cxCaps ) ¼¥H MAXCHR_IDX¡AMAXCHR_IDX ¬O°Ñ¼Æ¦W¤¤¦r¥À³Ì¦hªº¡C«á±ªº 6¡ÑcxChar ¬O¦A¥[¤W¤»Ó¦r¤¸¼¥H¦r¤¸ªº¥§¡¼e«×¡A¬°¦ó¬O¤»Ó¦r¤¸©O¡H¦]¬°²Ä¤@Äæ»P²Ä¤GÄ椧¶¡¥Î¨âӪťէ@¬°¶¡¹j¡AÁÙn¦A¥[¤W²Ä¤GÄ檺¼Æȳ̦h¬O¥|¦ì¼Æ¡A©Ò¥H¦³¤»Ó¦r¤¸¡CÁo©úªº§A¡AÀ³¸Ó¥i¥H¦Û¦æ±À¾É¥X x2¡Bx3¡A´N¤£¦h»¡¤F¡C
©³¤U¬O³B²z WM_CREATE °T®§ªºµ{¦¡½X¡G
122 123 124 125
126 127 128 129
130 131 132 133
134 135 136 137
138 139 140 141
142 143 144 145
146 147 148 149
150 151 152 153
154 155 156 157 158 |
.case WM_CREATE
invoke GetDC,hWnd
mov ps.hdc,rax
invoke GetTextMetrics,ps.hdc,ADDR tm
mov r10d,tm.tmAveCharWidth ;¨D±ocyChar¡BcxChar¡BcxCaps
mov r9d,tm.tmHeight
mov cxChar,r10d ;cxChar¡×tm.tmAveCharWidth¡×¦r¤¸¥§¡¼e«×
add r9d,tm.tmExternalLeading;cyChar¡×tm.tmHeight¡Ïtm.tmExternalLeading
shl r10d,1 ;¡@¡@¡@¡×¦r¤¸°ª«×¡A¤]¬O¨C¤@¦Cªº°ª«×
mov cyChar,r9d
test tm.tmPitchAndFamily,1 ;Ytm.tmPitchAndFamilyªº²Ä¹s¦ì¤¸¬°0¡Aªí¥Ü
jz fixed_width ;©T©w¼e«×¦r¤¸¡AcxCaps¡×¦r¤¸¥§¡¼e«×
add r10d,cxChar ;Ytm.tmPitchAndFamilyªº²Ä¹s¦ì¤¸¬°1¡Aªí¥Ü
fixed_width: shr r10d,1 ;¥iÅܼe«×¦r¤¸¡AcxCaps¡×¦r¤¸¥§¡¼e«×ªº1.5¿
mov cxCaps,r10d
;pºâ²Ä¤@Äæ»P²Ä¤GÄæ¥H¤Î¨âÄ椧¶¡ªº¨âªÅ®æ¡A¦@¤T¶µªºÁ`¼e«×¡Ax1¡C
;x1¡×MAXCHR_IDX¡ÑcxCaps+6¡ÑcxChar¡Ax1¬°²Ä¤GÄæ³Ì¥kÃä¦ì¸m
mov rax,MAXCHR_IDX
mul r10d
mov r11d,cxChar
mov r9d,cxChar
mov x1,eax
shl r11d,2
shl r9d,1 ;R9D¡×2¡ÑcxChar
add r11d,r9d ;R11D¡×6¡ÑcxChar
add x1,r11d
;pºâ²Ä¤TÄæ³Ì¥ªÃ䪺¦ì¸m¡Ax2¡Cx2¡×x1¡Ï2¡ÑcxChar
mov r8d,x1
add r8d,r9d
mov x2,r8d
;pºâ²Ä¥|Äæ³Ì¥kÃä¦ì¸m¡Ax3¡Cx3¡×x2¡ÏMAXCHR_NOTE¡ÑcxChar¡Ï6¡ÑcxChar
mov rax,MAXCHR_NOTE
mov x3,r8d
mul cxChar
add x3,eax
add x3,r11d
invoke ReleaseDC,hWnd,ps.hdc |
¥»³¹½g´T¤w¸g¤Ó¦h¤F¡A¦³Ãö SYSMTR1.ASM ªº»¡©ú¡A½Ð¨£¤U¤@³¹¡C