·í¨Ï¥ÎªÌ§â·Æ¹«´å¼Ð²¾¨ì¨Æ¥ý«ü©w¦nªº°Ï°ì®É¡A¨t²Î·|Åã¥Ü¤@µøµ¡¡A¦¹µøµ¡¥]§t¤@¬q¤å¦r»¡©ú¬Y¥ó¨Æ¡A³o¤@µøµ¡ºÙ¬°¤u¨ã´£¥Ü ( Tool Tip )¡C¦p¤U¹Ï©Ò¥Üªº¡uµn¿ý½s¿èµ{¦¡¡v¡A¦pªG¨Ï¥ÎªÌ¦b¥k¤W¨¤ªº¡u³Ì¤p¤Æ«ö¶s¡v«ö¶s°±¯d¤@¬q®É¶¡¡A´N·|¥X²{¤@Ó¶À©³¶Â¦rªº¤pµøµ¡¡A¤W±¼g¡u³Ì¤p¤Æ¡v¡A³oÓ¤pµøµ¡´N¬O¡u¤u¨ã´£¥Ü¡v¡C·L³n§â¨Æ¥ý«ü©w¦nªº°Ï°ìºÙ¬°¡utool¡v¡A¤p¤ì°¸Â½¦¨ºÊµø°Ï°ì¡A·í¨Ï¥ÎªÌ§â·Æ¹«´å¼Ð¥ÑºÊµø°Ï°ì²¾¨«®É¡A¤u¨ã´£¥Ü±Û§Y®ø¥¢¡C¡u¤u¨ã´£¥Ü¡v¤]¬O¤@ºØ³q¥Î±±¥ó¡C
¤u¨ã´£¥Ü±±¨î¶µÁÙ¦³¥t¥~´XºØ¸û¯S®í¼Ë¤l¡GTracking ToolTips ( ¥i¥H¥Ñµ{¦¡¦Ó«D¨t²Î³]©w¦bÅã¥Ü¦ì¸mªº¤u¨ã´£¥Ü )¡BMultiline ToolTips ( ¦h¦æªº¤u¨ã´£¥Ü )¡BBalloon ToolTips ( ®ð²y§Îª¬ªº¤u¨ã´£¥Ü )¡BIn-Place ToolTips ( ¥H·Æ¹«ÂI¿ï«á¥X²{ªº¤u¨ã´£¥Ü )¡C¤£¹L¤£ºÞ¬Oþ¤@ºØ¤u¨ã´£¥Ü¡A¨ä¹ê¤]³£¬O¤lµøµ¡¡A©Ò¥Hn«Ø¥ß¤u¨ã´£¥Ü¡A¥i¥H¥Î©I¥s CreateWindowEx¡C¦¹¨BÆJ¬°¡G
©I¥s CreateWindowEx «Ø¥ß¤u¨ã´£¥Ü®É¡A²Ä¤@ӰѼơAdwExStyle¡A¥i³]¬° NULL¡F²Ä¤GӰѼơAlpClassName¡A¶·«ü¦V¡yTOOLTIPS_CLASS32¡z¦r¦ê¦ì§}¡F²Ä¤TӰѼơAlpWindowName¡A¦]¤£»Ýµøµ¡¼ÐÃD¡A¥i³]¬° NULL¡F²Ä¥|ӰѼơAdwStyle¡A¦³¤CºØ·®æ¥i¨Ñ¿ï¾Ü¡G
·®æ | ¼ÆÈ | »¡©ú |
TTS_ALWAYSTIP | 1h | ¥un·Æ¹«¦bºÊµø°Ï°ì¤W¡A´N·|Åã¥Ü¤u¨ã´£¥Ü¡A¤£½×¤÷µøµ¡¬O§_¬O¬¡°Êªº¡C¦pªG¨S¦³³]©w¦¹·®æ¡A¥u¦³¦b¤÷µøµ¡¬°¬¡°Êªº®ÉÔ¡A¤~·|Åã¥Ü¤u¨ã´£¥Ü¡C |
TTS_BALLOON | 40h | ¦¹·®æ¬° 5.80 ª©¥»ªº COMCTRL32.DLL ¤Î¨ä¥H«á¤~¦³ªº·®æ¡A5.80 ª©¥»ªº COMCTL32.DLL ¬OÀH Internet Explorer 5 ( IE5 ) ´²§Gªº¡A¦]¦¹¦b¦w¸Ë¦³ IE5 ªº Windows §@·~¨t²Î¤¤¡A´N¥i¨Ï¥Î¦¹·®æ¡C¦¹·®æªº¤u¨ã´£¥Ü¦p¦Pº©µe¤¤¡A¤Hª«ªº¹ï¸Ü®Ø®Ø¡A¦p¹Ï¡C |
TTS_NOANIMATE | 10h | ¦¹·®æ¬° 5.80 ª©¥»ªº COMCTRL32.DLL ¤Î¨ä¥H«á¤~¦³ªº·®æ¡C¤@¯ë¦Ó¨¥¡A¤u¨ã´£¥Ü¥X²{®É¡A·|³vº¥¯B²{¦b¿Ã¹õ¤W¡F®ø¥¢®É¡A¬O³vº¥Áô¨S¡C¦pªG±z·Q¬Ý¨£«ez®ÄªG¡A¥²¶·¥H·Æ¹«¥kÁä«ö¡u§Úªº¹q¸£¡v¡÷¡u¤º®e¡v¡÷¡u¶i¶¥¡v¡÷¡u³]©w¡v¡÷¡uµøı®ÄªG¡v¡A½T©w¡u¦Ûq¡v¤¤¡u¤u¨ã´£¥Ü³vº¥®ø¥¢©Î·Æ°Ê¨ìÀ˵ø¡v¬°¤Ä¿ï¡C¦¹·®æ·|§í¨î³vº¥¯B²{¦b¿Ã¹õ¤Wªº®ÄªG¡C |
TTS_NOFADE | 20h | ¦¹·®æ¬° 5.80 ª©¥»ªº COMCTRL32.DLL ¤Î¨ä¥H«á¤~¦³ªº·®æ¡A¦¹·®æ·|§í¨î³vº¥Áô¨Sªº®ÄªG¡C |
TTS_NOPREFIX | 2h | ¨ã¦³¦¹·®æ®É¡A¤u¨ã´£¥Ü¯àÅã¥Ü¡y&¡z¦r¤¸¡C |
TTS_CLOSE | 80h | ¦pªG¤u¨ã´£¥Ü¨ã¦³¼ÐÃD¡A¥B¨ã¦³ TTS_CLOSE ®É¡A·|¦b¤u¨ã´£¥Ü¥k¤W¤èÅã¥ÜÃö³¬«ö¶s¡C§ÚÌ¥i¥H¹ï¤u¨ã´£¥Üµo°e TTM_SETTITLE ³]©w¼ÐÃD¡C |
TTS_USEVISUALSTYLE | 100h | ¨ã¦³¦¹·®æ®É¡A¯àÅã¥Ü¥DÃD³sµ²¡A»Ýn©M TTF_PARSELINKS ·f°t¨Ï¥Î¡C |
°£¦¹¤§¥~¡A¤u¨ã´£¥ÜÁÙ¨ã³Æ¦³ WS_POPUP ©MÃB¥~ªº WS_EX_TOOLWINDOW ·®æ¡A¦ý³o¨âºØ·®æ·|¥Ñ¡yTOOLTIPS_CLASS32¡zÃþ§O«ü©w¡A©Ò¥H¤£»Ý¯S§O«ü©w¡C±µ¤U¨Óªº¥|ӰѼƬOµøµ¡¦ì¸m»Pµøµ¡¤j¤p§¡¥Ñ¨t²Î³]©w¡A¬Ò³]¬°¡yCW_USEDEFAULT¡z§Y¥i¡C²Ä¤EӰѼơAhWndParent¡A¥i¥H¶ñ¤J¤÷µøµ¡¥N½X¡C²Ä¤QӰѼơAhMenu¡A¤£»Ýn¡A¦]¬°¤u¨ã´£¥Ü¤£·|¦³¿ï³æ¡A³]¬° NULL¡C²Ä¤Q¤@ӰѼơAhInstance¡AÀ³¶ñ¤J¤u¨ã´£¥Ü©ÒÄݪº¼Ò²Õ¥N½X¡C³Ì«á¤@ӰѼơAlpParam¡A«h¬O»Ýn¦Ó©w¡C
»P¨ä¥L±±¨î¶µ¤@¼Ë¡A§^¤H¥H©I¥s SendMessage ¹ï¤u¨ã´£¥Üµo¥X°T®§¡A¥H³]©w¨ä¦æ¬°¡C¦¹®É²Ä¤@ӰѼơAhWnd¡A¶ñ¤J¤u¨ã´£¥Ü¥N½X¡F²Ä¤GӰѼơAuMsg¡A¶·¨Ì¤£¦P»Ýn¦Ó³]©w¡A¤u¨ã´£¥Üªº°T®§³£¬O¥H¡uTTM_¡v¬°¦rÀY¡F²Ä¤T»P³Ì«á¤@ӰѼơAwParam »P lParam¡A«h¬O¨Ì uMsg ¤£¦P¦Ó³]¤£¦Pªº¼ÆÈ¡C¦p¤U¡J
INVOKE SendMessage,hToolTip,uMsg,wParam,lParam
©³¤U¥ý¤¶²Ð¦p¦ó¦b¤u¨ã´£¥Ü¤¤¡A·s¼WºÊµø°Ï°ì¡A¥ç§Yµo°e TTM_ADDTOOL °T®§µ¹¤u¨ã´£¥Ü¡C
¹ï¤u¨ã´£¥Üµo¥X TTM_ADDTOOL °T®§®É¡AwParam ¥²¶·³]¬° 0¡AlParam ¬O TOOLINFO µ²ºcÅé¦ì§}¡CTOOLINFO µ²ºcÅé¥]§t¤F¦³ÃöºÊµø°Ï°ìªº¸ê®Æ¤ÎnÅã¥Üªº¤å¦r¡A¥¦ªºÄæ¦ì¦p¤U¡G
TOOLINFO STRUC cbSize DWORD ? uFlags DWORD ? hwnd DWORD ? uId DWORD ? rect RECT <?> hinst DWORD ? lpszText DWORD ? lParam DWORD ? TOOLINFO ENDS
TOOLINFO ªº²Ä¤@ÓÄæ¦ì¡AcbSize¡A¬O TOOLINFO µ²ºcÅé¤j¤p¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡A¦b©I¥s SendMessage ¤§«e¥²¶·¶ñ¤J¥¿½Tªº¤j¤p¡A¥H«KÅý§@·~¨t²Î¯à¿ëÃѪ©¥»¡CTOOLINFO ªº²Ä¤ÓÄæ¦ì¡Arect¡A´N¬OºÊµø°Ï°ì¡AºÊµø°Ï°ì¨ä¹ê¬O¤@¶ô¯x§Î°Ï°ì¡A§Ú̦³®É§â¾ãÓ¤u§@°Ï³£·í¦¨ºÊµø°Ï°ì ( ¨Ò¦p§â«ö¶s±±¨î¶µ·í¦¨ºÊµø°Ï°ì®É¡A´N«Ü¦n¥Î )¡F¦³®É¶È¶È§â³¡¥÷¤u§@°Ï·í¦¨ºÊµø°Ï°ì¡A¦³®É¥ç¥i§â¤u§@°Ï¤Á³Î¦¨¼ÆÓ¯x§Î°Ï°ì¡A·í¦¨¼ÆӺʵø°Ï°ì¡A·Æ¹«²¾¹L¤£¦PªººÊµø°Ï°ì¥i¥HÅã¥Ü¤£¦Pªº¤å¦r¡C©³¤U¤p¤ì°¸¤À§O»¡©ú³o¨âºØ±¡§Î¡G
µo°e TTM_ADDTOOL µ¹¤u¨ã´£¥Ü«á¡A¦pªGªð¦^®É¡AEAX ¬° TRUE ªí¥Ü©I¥s¦¨¥\¡AY¬° FALSE ªí¥Ü¥¢±Ñ¡C
TOOLINFO ¤]¥i¥H¬°¨ä¥¦°T®§¨Ï¥Î¡A¦p TTM_DELTOOL¡A¦]¦¹ uFlags Äæ¦ì¥\¯à¤£¬O¥u¦³ TTF_IDISHWND ©M TTF_SUBCLASS ¨âºØ¦Ó¤w¡A¤p¤ì°¸¾ã²z¦p¤U¡J
TOOLINFO µ²ºcÅ骺 lpszText Äæ¦ì¥i¥H¬O¦r¦ê¦ì§}¡A¤]¥i¥H¬O¦r¦ê¸ê·½ªºÃѧO½X¡A°²¦p¬O«áªÌ¡A¨º»òÁÙn¦A³]©w hinst Äæ¦ì¡Ahinst ¬O¥]§t¦³¤å¦r¦r¦ê¸ê·½ªº¼Ò²Õ¥N½X¡A¥¦¥u¦³¦b lpszText ¬O¥Nªí¦r¦ê¸ê·½ªºÃѧO½X®É¤~»Ýn³]©w¡A¨ä¥L±¡§Î¬OµL¥Îªº¡C³Ì«á¤@ÓÄæ¦ì lParam
µo°e TTM_SETDELAYTIME °T®§µ¹¤u¨ã´£¥Ü¡A¥i¥H³]©w¤u¨ã´£¥Üªº©µ¿ð®É¶¡¡A¤èªk¬O¡J
INVOKE SendMessage,hToolTip,TTM_SETDELAYTIME,wParam,lParam
¨ä¤¤³Ì«á¤@ӰѼơAlParam¡A¬O«ü©µ¿ðªº®É¶¡¡A¥H²@¬í¬°³æ¦ì¡C¦Ó wParam ¬O³]©w©µ¿ðþ¤@ºØ®É¶¡¡A¥i¥H¬O¤U±´X¥|ºØ¡J
³oÓ°T®§¬O¥Î¨Ó³]©w¤u¨ã´£¥Üªº³Ì¤j¼e«×¡C§ÚÌ¥i¥H¥Î³oºØ¤èªk¨Ó³]©w¦h¦æ¦r¦ê¡C¤èªk¦p¤U¡J
INVOKE SendMessage,hToolTip,TTM_SETMAXTIPWIDTH,0,iWidth
°Ñ¼Æ¤¤ªº wParam ¥²¶·³]¬° 0¡A¦Ó lParam ¬°n³]©wªº¼e«×¡A¥HÂI¬°³æ¦ì¡C¦pªGnÅã¥Üªº¦r¦êªø«×¶W¹L¤u¨ã´£¥Üªº³Ì¤j¼e«×¡A¨º»ò³Ñ¤Uªº¦r¦ê·|Åã¥Ü¦b¤U¤@¦æ¡C³oùةҿתº³Ì¤j¼e«×¡A¨Ã¤£¬O«ü¤u¨ã´£¥Ü¤£¯à¶W¹L¦¹¼e«×¡C¦]¬°^¤å¦rªøµu¤£¦P¡A¨Ã¥B¦Ò¼{¤£nÅý¤@Ó^¤å¦r¤Á¦¨¨â¦æ¡A©Ò¥H¨t²Î¦b¦r¦ê¶W¹L³Ì¤j¼e«×®É¡A¦p¹JªÅ¥Õ¦r¤¸¡A¤~·|³Q¤Á¦¨¨â¦æ¡C¦¹¥~¡A¦pªG¨S¦³³]©w TTM_SETMAXTIPWIDTH¡A§Y¨Ï¨Ï¥Î´«¦æ¦r¤¸ ( 0dh¡B0ah ) ¤]¤£¯à¤Á¦¨¨â¦æ¡F¦ý¬O³]©w¹L TTM_SETMAXTIPWIDTH «á¡A§Y¨Ï¦b³Ì¤j¼e«×¤º¡A¨Ï¥Î´«¦æ¦r¤¸¤]¥i¥H´«¦æ¡C
³oÓ°T®§¬O¥Î¨Ó¦b¤u¨ã´£¥Ü¤ºªº¤W¤èÅã¥Ü¼ÐÃD¡C¤èªk¦p¤U¡J
INVOKE SendMessage,hToolTip,TTM_SETTITLE,icon,pszTitle
°Ñ¼Æ icon ¬O¦b¼ÐÃDÄ楪¤è³]©w¹Ï¥Ü¡A¥i¥H¬O¤U±´XºØ¡JTTI_NONE¡BTTI_INFO¡BTTI_WARNING¡BTTI_ERROR¡BTTI_INFO_LARGE¡BTTI_WARNING_LARGE¡BTTI_ERROR_LARGE¡A¦pªG¬O Windows XP SP2 ¥H«áªºª©¥»¡A¤]¥i¥H¨Ï¥Î¹Ï¥Ü¥N½X¡CpszTitle ¬°¼ÐÃD¦r¦ê¦ì§}¡A¥H¹sµ²§À¡Cªð¦^®É¡ATRUE ªí¥Ü¦¨¥\¡FFALSE ªí¥Ü¥¢±Ñ¡C
©³¤U¤p¤ì°¸±N¹ê§@¤@Óµ{¦¡¡AMEMFREE1.ASM¡A¦¹µ{¦¡·|§â¹q¸£¤¤ªº³Ñ¾lªº¹êÅé°O¾ÐÅé¡B¤À¶ÀÉ¡BµêÀÀ°O¾ÐÅéÅã¥Ü¥X¨Ó¡A·í¨Ï¥ÎªÌ§â·Æ¹«²¾¨ì¬ÛÃöªº¸ê®Æ®É¡A´N·|¥X²{¤u¨ã´£¥Ü¡A¸ÑÄÀ¬ÛÃöªº³N»y¡C
.586 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE WINDOWS.INC INCLUDE GDI32.INC INCLUDE KERNEL32.INC INCLUDE USER32.INC INCLUDE COMCTL32.INC INCLUDELIB GDI32.LIB INCLUDELIB KERNEL32.LIB INCLUDELIB USER32.LIB INCLUDELIB COMCTL32.LIB GlobalMemoryStatusEx PROTO :DWORD MEMORYSTATUSEX STRUC dwLength DWORD ? dwMemoryLoad DWORD ? ullTotalPhys QWORD ? ullAvailPhys QWORD ? ullTotalPageFile QWORD ? ullAvailPageFile QWORD ? ullTotalVirtual QWORD ? ullAvailVirtual QWORD ? ullAvailExtendedVirtual QWORD ? MEMORYSTATUSEX ENDS ;********************************************************************* .CONST WND_WIDTH EQU 200 WND_HEIGHT EQU 120 ID_TIMER EQU 2000 FONT_SIZE EQU 12 TTF_ABSOLUTE EQU 80h TTF_TRACK EQU 20h TTM_TRACKPOSITION EQU 412h TTM_SETMAXTIPWIDTH EQU 418h TTM_TRACKACTIVATE EQU WM_USER + 17 rect RECT <0,0,WND_WIDTH,WND_HEIGHT> szAppName BYTE '³Ñ¾l°O¾ÐÅé',0 szClassName BYTE 'MemFree',0 szMemIcon BYTE 'CHIP',0 szToolTipClass BYTE 'TOOLTIPS_CLASS32',0 szFont BYTE '·s²Ó©úÅé',0 szMemFmt BYTE '¥þ³¡¹êÅé°O¾ÐÅé¡G%dKB',0dh,0ah,'³Ñ¾l¹êÅé°O¾ÐÅé¡G%dKB',0dh,0ah BYTE '¥þ³¡¤À¶Àɤj¤p¡G%dKB',0dh,0ah,'³Ñ¤U¤À¶Àɤj¤p¡G%dKB',0dh,0ah BYTE '¥þ³¡µêÀÀ°O¾ÐÅé¡G%dKB',0dh,0ah,'³Ñ¤UµêÀÀ°O¾ÐÅé¡G%dKB',0 szPhyMem BYTE '¹êÅé°O¾ÐÅé¬O«ü¦w¸Ë¦b¹q¸£¥D¾÷ªO',0dh,0ah BYTE '¤Wªº°ÊºAÀH¾÷¦s¨ú°O¾ÐÅé ( Dynamic ',0dh,0ah BYTE 'Random Access Memory¡A²ºÙ DRAM )',0dh,0ah BYTE '¥¦¬O¤@ÁûÁûªº¿nÅé¹q¸ô²Õ¦¨ªº¡C',0 szPageFile BYTE '¤À¶ÀÉ¥»«ü«Ø¥ß¦bµwºÐ¤¤ªºµêÀÀ°O¾Ð',0dh,0ah BYTE 'Åé¡A¦¹³B¬O«ü¹êÅé°O¾ÐÅé»P¤À¶Àɤj',0dh,0ah BYTE '¤p¡A¤]¬O¨t²Î©Ò¯à¨Ï¥Îªº°O¾ÐÅé¤W',0dh,0ah BYTE '¤j¤p»P³Ñ¾l¤j¤p¡C',0 szVirtual BYTE '¤@Óµ{¦¡©Ò¯à¨Ï¥ÎªºµêÀÀ°O¾ÐÅé¡A¦¹',0dh,0ah BYTE 'µêÀÀ°O¾ÐÅ饲¶·¦©°£¨t²Î¥Î¥hªº³¡¥÷',0dh,0ah BYTE '¡A¹ï Win32 ¨t²Î¦Ó¨¥¤j¬ù¬O 2GB¡C',0 ;********************************************************************* .DATA? hInstance HINSTANCE ? hwnd HWND ? hFont HFONT ? hWndToolTip HWND ? wc WNDCLASSEX <?> msg MSG <?> msex MEMORYSTATUSEX <?> iccex INITCOMMONCONTROLSEX <?> ti TOOLINFO <?> buffer BYTE 160 DUP (?) ;********************************************************************* .CODE ;--------------------------------------------------------------------- BytesToKB PROC shl edx,22 shr eax,10 add eax,edx ret BytesToKB ENDP ;--------------------------------------------------------------------- SetToolInfo PROC id:DWORD sub edx,edx mov eax,id mov ti.uId,eax mov ecx,FONT_SIZE*2 mul ecx mov ti.rect.top,eax mov ti.rect.left,0 add eax,ecx mov ti.rect.right,WND_WIDTH mov ti.rect.bottom,eax .IF id==0 mov ti.lpszText,OFFSET szPhyMem .ELSEIF id==1 mov ti.lpszText,OFFSET szPageFile .ELSEIF id==2 mov ti.lpszText,OFFSET szVirtual .ENDIF INVOKE SendMessage,hWndToolTip,TTM_ADDTOOL,0,OFFSET ti ret SetToolInfo ENDP ;--------------------------------------------------------------------- WndProc PROC hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL ps:PAINTSTRUCT LOCAL hDC:HDC .IF uMsg==WM_PAINT INVOKE BeginPaint,hWnd,ADDR ps INVOKE CreateFont,FONT_SIZE,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,\ OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,\ NULL,OFFSET szFont mov hFont,eax INVOKE SelectObject,ps.hdc,eax INVOKE DeleteObject,eax mov msex.dwLength,SIZEOF MEMORYSTATUSEX INVOKE GlobalMemoryStatusEx,OFFSET msex mov edx,DWORD PTR msex.ullAvailVirtual[4] mov eax,DWORD PTR msex.ullAvailVirtual call BytesToKB push eax mov edx,DWORD PTR msex.ullTotalVirtual[4] mov eax,DWORD PTR msex.ullTotalVirtual call BytesToKB push eax mov edx,DWORD PTR msex.ullAvailPageFile[4] mov eax,DWORD PTR msex.ullAvailPageFile call BytesToKB push eax mov edx,DWORD PTR msex.ullTotalPageFile[4] mov eax,DWORD PTR msex.ullTotalPageFile call BytesToKB push eax mov edx,DWORD PTR msex.ullAvailPhys[4] mov eax,DWORD PTR msex.ullAvailPhys call BytesToKB push eax mov edx,DWORD PTR msex.ullTotalPhys[4] mov eax,DWORD PTR msex.ullTotalPhys call BytesToKB push eax push OFFSET szMemFmt push OFFSET buffer call wsprintf INVOKE DrawText,ps.hdc,OFFSET buffer,eax,OFFSET rect,DT_LEFT INVOKE EndPaint,ps.hdc,ADDR ps .ELSEIF uMsg==WM_TIMER INVOKE InvalidateRect,hWnd,NULL,TRUE .ELSEIF uMsg==WM_CREATE INVOKE SetTimer,hWnd,ID_TIMER,1000,NULL mov iccex.dwSize,SIZEOF INITCOMMONCONTROLSEX mov iccex.dwICC,ICC_BAR_CLASSES INVOKE InitCommonControlsEx,OFFSET iccex INVOKE CreateWindowEx,0,OFFSET szToolTipClass,0,TTS_NOPREFIX OR TTS_ALWAYSTIP,\ CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hWnd,0,hInstance,0 mov hWndToolTip,eax INVOKE SendMessage,eax,TTM_SETMAXTIPWIDTH,0,200 mov ecx,hWnd mov ti.cbSize,SIZEOF TOOLINFO mov ti.uFlags,TTF_SUBCLASS mov ti.hWnd,ecx INVOKE SetToolInfo,0 INVOKE SetToolInfo,1 INVOKE SetToolInfo,2 .ELSEIF uMsg==WM_DESTROY INVOKE KillTimer,hWnd,ID_TIMER INVOKE PostQuitMessage,NULL .ELSE INVOKE DefWindowProc,hWnd,uMsg,wParam,lParam ret .ENDIF xor eax,eax ret WndProc ENDP ;--------------------------------------------------------------------- start: INVOKE GetModuleHandle,NULL mov hInstance,eax mov wc.cbSize,SIZEOF WNDCLASSEX mov wc.style,CS_HREDRAW OR CS_VREDRAW OR CS_DBLCLKS mov wc.lpfnWndProc,OFFSET WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL mov wc.hInstance,eax INVOKE LoadIcon,eax,OFFSET szMemIcon mov wc.hIcon,eax mov wc.hIconSm,eax INVOKE LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax mov wc.hbrBackground,COLOR_WINDOW+1 mov wc.lpszMenuName,NULL mov wc.lpszClassName,OFFSET szClassName INVOKE RegisterClassEx,OFFSET wc INVOKE GetSystemMetrics,SM_CXSCREEN sub eax,WND_WIDTH shr eax,1 push eax INVOKE GetSystemMetrics,SM_CYSCREEN sub eax,WND_HEIGHT pop edx shr eax,1 INVOKE CreateWindowEx,NULL,OFFSET szClassName,OFFSET szAppName,\ WS_SYSMENU OR WS_MINIMIZEBOX,edx,eax,WND_WIDTH,WND_HEIGHT,0,\ NULL,hInstance,NULL mov hwnd,eax INVOKE ShowWindow,eax,SW_SHOWDEFAULT INVOKE UpdateWindow,hwnd .WHILE TRUE INVOKE GetMessage,OFFSET msg,NULL,0,0 .BREAK .IF !eax INVOKE TranslateMessage,OFFSET msg INVOKE DispatchMessage,OFFSET msg .ENDW mov eax,msg.wParam INVOKE ExitProcess,eax ;********************************************************************* END start
¸ê·½ÀÉ¡AMEMFREE.RC¡A¶È¤@¦æ¡G
CHIP ICON CHIP3.ico
¨Ì¤U±¤èªk²ÕĶ¡G
E:\HomePage\SOURCE\Win32\TOOLTIP>rc memfree.rc [Enter] E:\HomePage\SOURCE\Win32\TOOLTIP>ml memfree1.asm /link memfree.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: memfree1.asm Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "memfree1.obj" "/OUT:memfree1.exe" "memfree.res" E:\HomePage\SOURCE\Win32\TOOLTIP>
±zÀ³·í¥i¥H¨£¨ì¡AMEMFREE.EXE ¦b³B²z WM_CREATE ®É¡A©I¥s CreateWindowEx «Ø¥ß¤F¤u¨ã´£¥Ü±±¨î¶µ¡AµM«á§â³oÓµøµ¡¥N½X¦s¦b hWndToolTip ÅܼÆùØ¡C±µµÛ¥H TTM_SETMAXTIPWIDTH ¬°°Ñ¼Æ©I¥s SendMessage¡A³o¤@Ó¨BÆJ¬O¨î¤u¨ã´£¥Üªº¼e«×¡C¤@¯ë¦Ó¨¥¡A¤u¨ã´£¥Ü·|©¿²¤´«¦æ¡BÂk¦ì¦r¤¸¡A©Ò¥H§Y¬O¦r¦ê¥]§t³o¨âÓ¦r¤¸¡A¤u¨ã´£¥Ü¤´¬OÅã¥Ü¤@¦æ¡C¦pªG¨î¤F¤u¨ã´£¥Ü¼e«×¡A´N¥i¥H¨Ï¥¦¦b¶W¹L¦¹¼e«×¤§«e¦Û°Ê¨ì¤U¤@¦æÅã¥Ü¡C
·QnÀò¨ú°O¾ÐÅé¨Ï¥Î±¡§Î¸ê®Æ¡A¥i¥H©I¥s¦´Áªº GlobalMemoryStatus ©Î¬O GlobalMemoryStatusEx¡A¨âªÌ®t§O¦b«áªÌ¥u¯à¦b Windows 2K/XP ¤Î¥H«áªºª©¥»¡A¦ý¬O¦pªG¹q¸£¤¤¤w¦w¸Ë¶W¹L 4GB ªº°O¾ÐÅé¡AGlobalMemoryStatusEx ¤]¯à¦b 64 ¦ì¤¸ªº§@·~¨t²Î±o¨ì¶W¹L 4GB ªº°O¾ÐÅé¸ê®Æ¡F¦Ó GlobalMemoryStatus «hµLªk¿ì¨ì¡CGlobalMemoryStatusEx ªºì«¬¦b MASM32 v7.0 ¨Ã¨S¦³©w¸q¡A¨ì¤F MASM32 v8.2 ¥H«áªºª©¥»¤~¦b KERNEL32.INC ¤¤©w¸q¡A©Ò¥H°²¦p±z¨Ï¥Î MASM32 v7.0 ²ÕĶªº¸Ü¡A½Ð¦Û¦æ¥[¤J¡G
GlobalMemoryStatusEx PROTO :DWORD
GlobalMemoryStatusEx ¥u¦³¤@ӰѼơA¦¹°Ñ¼Æ«ü¦V MEMORYSTATUSEX µ²ºcÅ骺¦ì§}¡A³oÓµ²ºcÅé¦b MASM32 v7¡ã10 ³£¨S¦³©w¸q¡A©Ò¥H±o¦Û¦æ¦bì©l½X¤¤©w¸q¡A¨äÄæ¦ì¦p¤U¡G
MEMORYSTATUSEX STRUC dwLength DWORD ? dwMemoryLoad DWORD ? ullTotalPhys QWORD ? ;¹q¸£¦w¸Ëªº¹êÅé°O¾ÐÅé¤j¤p ullAvailPhys QWORD ? ;³Ñ¾l¹êÅé°O¾ÐÅé¤j¤p ullTotalPageFile QWORD ? ;¨t²Î©Ò¯à¨Ï¥Îªº°O¾ÐÅé¤W¡A¥]§t¤À¶ÀÉ»P¹êÅé°O¾ÐÅé¤j¤p ullAvailPageFile QWORD ? ;³Ñ¾l¤À¶ÀÉ»P¹êÅé°O¾ÐÅé¤j¤p ullTotalVirtual QWORD ? ;µêÀÀ°O¾ÐÅé¤j¤p ullAvailVirtual QWORD ? ;³Ñ¾lµêÀÀ°O¾ÐÅé¤j¤p ullAvailExtendedVirtual QWORD ? ;³Ñ¾l©µ¦ùµêÀÀ°O¾ÐÅé¤j¤p MEMORYSTATUSEX ENDS
²Ä¤@ÓÄæ¦ì¡AdwLength¡A¬O MEMORYSTATUSEX µ²ºcÅ骺¤j¤p¡A¥H¦ì¤¸²Õ¬°³æ¦ì¡A¥²¶·¦b©I¥s GlobalMemoryStatusEx «e¶ñ¦n³oÓÄæ¦ì¡C¥Ñ²Ä¤GÓÄæ¦ì¨ì³Ì«áªºÄæ¦ì¬O©I¥s GlobalMemoryStatusEx ¤§«á¡A¥Ñ§@·~¨t²Î¶ñ¤Wªº¡C²Ä¤GÓÄæ¦ì¡AdwMemoryLoad¡Aªí¥Ü¹êÅé°O¾ÐÅé¤w¨Ï¥Îªº¦Ê¤À¤ñ¡A¬O 0 ¨ì 100 ªº¾ã¼Æ¡C¨ä¾lªºÄæ¦ì³£¬O¦U¦¡°O¾ÐÅ骺¤j¤pªº¸ê®Æ¡A¥þ¬O¥H¦ì¤¸²Õ¬°³æ¦ì¡C¦pªG GlobalMemoryStatusEx ¦¨¥\ªº¶Ç¦^ MEMORYSTATUSEX µ²ºcÅé¡A«h EAX ¬°«D¹sÈ¡A§_«h EAX ¬°¹s¡C¦pªG±z¥Î MASM32 v7.0 ²ÕĶ¡A¦]¨ä KERNEL32.LIB ¨Ã¥¼¥]§t GlobalMemoryStatusEx ªº¸ê®Æ¡A·|§Î¦¨µLªk³sµ²ªº±¡§Î¡A½Ð§ï¥Î MASM32 v9.0 ¥H¤W²ÕĶ¡A©Î¬O¦b·L³nºô¯¸¤U¸ü 6.0.6001.18000.367-KRMSDK_EN.iso¡A³o¬O Windows SDK for Windows Server 2008 ªº¥úºÐ¼v¹³ÀÉ¡A¦b¨ä¡y\Setup\WinSDKBuild-WinSDKBuild_VistaLibs_X86-common.0.cab¡zÀ£ÁYÀɤ¤µÑ¨ú¡yKernel32_Lib.34A9A805_A741_4A0D_A5EA_FE0276BE952C¡zÀɮסA±N¨ä§ï¦W¬°¡yKERNEL32.LIB¡z¡A¦A½Æ¼g¨ì¡yC:\MASM32\LIB¡z¤l¥Ø¿ýùؤ]¥i¥H²ÕĶ¦¨¥\¡C
¦Ü©ó GlobalMemoryStatus API »P GlobalMemoryStatusEx ¬Û¦P¡A¤]³£¥u¦³¤@ӰѼơA¦¹°Ñ¼Æ¬O«ü¦V MEMORYSTATUS µ²ºcÅ骺¦ì§}¡AMEMORYSTATUS µ²ºcÅé»P MEMORYSTATUSEX ¤]«Ü¬Û¦ü¡A¨ä®t§O¬O MEMORYSTATUS µ²ºcÅé¤Ö¤F³Ì«á¤@ÓÄæ¦ì¡A¦Ó¥B©Ò¦³Äæ¦ìªºªø«×³£¬OÂù¦r²Õ¡AGlobalMemoryStatus »P MEMORYSTATUS ¦b MASM32 v7.0 ³£¤w©w¸q¡A¤£¶·§Ú̶O¤ß¡C