ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡ÔĶÁ¹ý³Ì·¢ÏÖÈκδíÎóÇë¸æËßÎÒÃÇ£¬Ð»Ð»£¡£¡ ±¨¸æ´íÎó
ÒÀÒÀС˵ ·µ»Ø±¾ÊéĿ¼ ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ½øÈëÊé°É ¼ÓÈëÊéÇ©

windows»·¾³ÏÂ32λ»ã±àÓïÑÔ³ÌÐòÉè¼Æ-µÚ3²¿·Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡



£»×¨ÓÃÓڵ绰·þÎñ·½ÃæµÄAPI³ÆΪTAPI£¨Telephony¡¡API£©£¬°üº¬ÔÚTapi32¡£dllÖС£ËùÓеÄÕâЩDLLÌṩµÄº¯Êý×é³ÉÁËÏÖÔÚËùÓõÄWin32±à³Ì»·¾³¡£

¡¡

3¡£2¡£2¡¡¡¡µ÷ÓÃAPI

ºÍÔÚDOSÖÐÓÃÖжϷ½Ê½µ÷ÓÃϵͳ¹¦ÄÜÒ»Ñù£¬ÓÃAPI·½Ê½µ÷Óôæ·ÅÔÚDLLÖеĺ¯Êý±ØÐëͬÑùÔ¼¶¨Ò»¸ö¹æ·¶£¬ÓÃÀ´¶¨Ò庯ÊýµÄµ÷Ó÷½·¨¡¢²ÎÊýµÄ´«µÝ·½·¨ºÍ²ÎÊýµÄ¶¨Ò壬ÑóÑóÈ÷È÷¼¸°ÙMBµÄWindowsϵͳ±ÈÆð²Å¼¸°ÙKB¹æÄ£µÄDOS£¬Æäϵͳº¯ÊýµÄ¹æÄ£ºÍ¸´Ôӳ̶ȶ¼ÉÏÁËÒ»¸öÊýÁ¿¼¶£¬ËùÒÔÔÚʹÓÃÒ»¸öAPIʱ£¬´øµÄ²ÎÊýÊýÁ¿¶à´ïÊ®¼¸¸öÊdz£ÓеÄÊ£¬ÔÚDOSÏÂÓüĴæÆ÷À´´«µÝ²ÎÊýµÄ·½·¨ÏÔÈ»ÒѾ­²»ÄÜʤÈÎÁË¡£

Win32¡¡APIÊÇÓöÑÕ»À´´«µÝ²ÎÊýµÄ£¬µ÷ÓÃÕ߰ѲÎÊýÒ»¸ö¸öѹÈë¶ÑÕ»£¬DLLÖеĺ¯Êý³ÌÐòÔÙ´Ó¶ÑÕ»ÖÐÈ¡³ö²ÎÊý´¦Àí£¬²¢ÔÚ·µ»Ø֮ǰ½«¶ÑÕ»ÖÐÒѾ­ÎÞÓõIJÎÊý¶ªÆú¡£ÔÚMicrosoft·¢²¼µÄ¡¶Microsoft¡¡Win32¡¡Programmer's¡¡Reference¡·Öж¨ÒåÁ˳£ÓÃAPIµÄ²ÎÊýºÍº¯ÊýÉùÃ÷£¬ÏÈÀ´¿´ÏûÏ¢¿òº¯ÊýµÄÉùÃ÷£º

int¡¡MessageBox£¨

¡¡¡¡¡¡¡¡HWND¡¡hWnd£»¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//¡¡handle¡¡to¡¡owner¡¡window

¡¡¡¡¡¡¡¡LPCTSTR¡¡lpText£»¡¡¡¡¡¡¡¡¡¡//¡¡text¡¡in¡¡message¡¡box

¡¡¡¡¡¡¡¡LPCTSTR¡¡lpCaption£»¡¡¡¡//¡¡message¡¡box¡¡title

¡¡¡¡¡¡¡¡UINT¡¡uType¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡//¡¡message¡¡box¡¡style

¡¡¡¡¡¡¡¡£©£»

×îºó»¹ÓÐÒ»¾ä˵Ã÷£º

Library£º¡¡Use¡¡User32¡£lib¡£

ÉÏÊöº¯ÊýÉùÃ÷˵Ã÷ÁËMessageBoxÓÐ4¸ö²ÎÊý£¬ËüÃÇ·Ö±ðÊÇHWNDÀàÐ͵Ĵ°¿Ú¾ä±ú£¨hWnd£©£¬LPCTSTRÀàÐ͵ÄÒªÏÔʾµÄ×Ö·û´®µØÖ·£¨lpText£©ºÍ±êÌâ×Ö·û´®µØÖ·£¨lpCaption£©£¬»¹ÓÐUINTÀàÐ͵ÄÏûÏ¢¿òÀàÐÍ£¨uType£©¡£ÕâЩÊý¾ÝÀàÐÍ¿´ÆðÀ´ºÜ¸´ÔÓ£¬µ«ÓÐÒ»µãÊǺÜÖØÒªµÄ£¬¶ÔÓÚ»ã±àÓïÑÔÀ´Ëµ£¬Win32»·¾³ÖеIJÎÊýʵ¼ÊÉÏÖ»ÓÐÒ»ÖÖÀàÐÍ£¬ÄǾÍÊÇÒ»¸ö32λµÄÕûÊý£¬ËùÓÐÕâЩHWND£¬LPCTSTRºÍUINTʵ¼ÊÉϾÍÊÇ»ã±àÖеÄdword£¨double¡¡word£©£¬Ö®ËùÒÔ¶¨ÒåΪ²»Í¬µÄÄ£Ñù£¬ÊÇÓÃÀ´ËµÃ÷ÓÃ;¡£ÓÉÓÚWindowsÊÇÓÃCд³ÉµÄ£¬ÊÀ½çÉϵijÌÐòÔ±ºÃÏñÒ²ÊÇÓÃCÓïÑÔµÄ×î¶à£¬ËùÒÔWindowsËùÓбà³Ì×ÊÁÏ·¢²¼µÄ¸ñʽҲÊÇC¸ñʽ¡£

ÉÏÃæµÄÉùÃ÷Óûã±àµÄ¸ñʽÀ´±í´ï¾ÍÊÇ£º

MessageBox¡¡Proto¡¡hWnd£ºdword£»lpText£ºdword£»lpCaption£ºdword£»uType£ºdword

ÉÏÃæ×îºóÒ»¾äLibrary£º¡¡Use¡¡User32¡£libÔò˵Ã÷ÁËÕâ¸öº¯Êý°üÀ¨ÔÚUser32¡£dllÖС£

ÓÐÁ˺¯ÊýÔ­Ð͵Ķ¨ÒåÒԺ󣬾ÍÊǵ÷ÓõÄÎÊÌâÁË£¬Win32¡¡APIµ÷ÓÃÖÐÒª°Ñ²ÎÊý·ÅÈë¶ÑÕ»£¬Ë³ÐòÊÇ×îºóÒ»¸ö²ÎÊý×îÏȽøÕ»£¬ÔÚ»ã±àÖе÷ÓÃMessageBoxº¯ÊýµÄ·½·¨ÊÇ£º

push¡¡¡¡¡¡¡¡uType

push¡¡¡¡¡¡¡¡lpCaption

push¡¡¡¡¡¡¡¡lpText

push¡¡¡¡¡¡¡¡hWnd

call¡¡¡¡¡¡¡¡MessageBox

ÔÚÔ´³ÌÐò±àÒëÁ´½Ó³É¿ÉÖ´ÐÐÎļþºó£¬call¡¡MessageBoxÓï¾äÖеÄMessageBox»á±»»»³ÉÒ»¸öµØÖ·£¬Ö¸Ïò¿ÉÖ´ÐÐÎļþÖеĵ¼Èë±í£¬µ¼Èë±íÖÐÖ¸ÏòMessageBoxº¯ÊýµÄʵ¼ÊµØÖ·»áÔÚ³ÌÐò×°ÈëÄÚ´æµÄʱºò£¬¸ù¾ÝUser32¡£dllÔÚÄÚ´æÖеÄλÖÃÓÉWindowsϵͳ¶¯Ì¬ÌîÈë¡£

1¡£¡¡Ê¹ÓÃinvokeÓï¾ä

APIÊÇ¿ÉÒÔµ÷ÓÃÁË£¬ÁíÒ»¸ö·³È˵ÄÎÊÌâÓÖ³öÏÖÁË£¬Win32µÄAPI¶¯éü¾ÍÊÇÊ®¼¸¸ö²ÎÊý£¬Õû¸öÔ´³ÌÐòÒ»ÑÛ¿´ÉÏÈ¥»ù±¾É϶¼ÊǰѲÎÊýѹÈë¶ÑÕ»µÄpushÖ¸Á²ÎÊýµÄ¸öÊýºÍ˳ÐòºÜÈÝÒ׸ã´í£¬ÓÉ´ËÒýÆðµÄĪÃûÆäÃîµÄ´íÎóÔ´Ô´²»¶Ï£¬Ô´³ÌÐòµÄ¿É¶ÁÐÔ¿´ÉÏÈ¥Ò²ºÜ²î¡£Èç¹ûдµÄʱºòÉÙдÁËÒ»¾äpushÖ¸Á³ÌÐòÔÚ±àÒëºÍÁ´½ÓµÄʱºò¶¼²»»á±¨´í£¬µ«ÔÚÖ´ÐеÄʱºò±Ø¶¨»á±ÀÀ££¬Ô­ÒòÊǶÑÕ»¶Ô²»ÆëÁË¡£

ÓÐûÓнâ¾öµÄ°ì·¨ÄØ£¿×îºÃÊÇÏñCÓïÑÔÒ»Ñù£¬ÄÜÔÚͬһ¾äÖдòÈëËùÓеIJÎÊý£¬²¢ÔÚ²ÎÊýʹÓôíÎóµÄʱºòÄܹ»Ìáʾ¡£

ºÃÏûÏ¢ÓÖÀ´ÁË£¬MicrosoftÖÕÓÚ×öÁËÒ»¼þºÃÊ£¬ÔÚMASMÖÐÌṩÁËÒ»¸öαָÁîʵÏÖÁËÕâ¸ö¹¦ÄÜ£¬ÄǾÍÊÇinvokeαָÁËüµÄ¸ñʽÊÇ£º

¡¡¡¡¡¡¡¡invoke¡¡¡¡º¯ÊýÃû£§£¬²ÎÊý1£§£§£¬²ÎÊý2£§¡­¡­

¶ÔMessageBoxµÄµ÷ÓÃÔÚMASMÖпÉÒÔд³É£º

invoke¡¡¡¡MessageBox£»NULL£»offset¡¡szText£»offset¡¡szCaption£»MB_OK

×¢Ò⣬invoke²¢²»ÊÇ80386´¦ÀíÆ÷µÄÖ¸Á¶øÊÇÒ»¸öMASM±àÒëÆ÷µÄαָÁÔÚ±àÒëµÄʱºòËü°ÑÉÏÃæµÄÖ¸ÁîÕ¹¿ª³ÉÎÒÃÇÐèÒªµÄ4¸öpushÖ¸ÁîºÍ1¸öcallÖ¸Áͬʱ£¬½øÐвÎÊýÊýÁ¿µÄ¼ì²é¹¤×÷£¬Èç¹û´øµÄ²ÎÊýÊýÁ¿ºÍÉùÃ÷ʱµÄÊýÁ¿²»·û£¬±àÒëÆ÷»á±¨´í£º

error¡¡A2137£º¡¡too¡¡few¡¡arguments¡¡to¡¡INVOKE

±àÒëʱ¿´µ½ÕâÑùµÄ´íÎ󱨸棬Ê×ÏÈÒª¼ì²éµÄÊÇÓÐûÓÐÉÙдÁËÒ»¸ö²ÎÊý¡£¶ÔÓÚ²»´ø²ÎÊýµÄAPIµ÷Óã¬invokeαָÁîµÄ²ÎÊý¼ì²é¹¦ÄÜ¿ÉÓпÉÎÞ£¬ËùÒԼȿÉÒÔÓÃcall¡¡API_NameÕâÑùµÄÓï·¨Ò²¿ÉÒÔÓÃinvoke¡¡API_NameÕâÑùµÄÓï·¨¡£

2¡£¡¡APIº¯ÊýµÄ·µ»ØÖµ

ÓеÄAPIº¯ÊýÓзµ»ØÖµ£¬ÈçMessageBox¶¨ÒåµÄ·µ»ØÖµÊÇintÀàÐ͵ÄÊý£¬·µ»ØÖµµÄÀàÐͶԻã±à³ÌÐòÀ´ËµÒ²Ö»ÓÐdwordÒ»ÖÖÀàÐÍ£¬ËüÓÀÔ¶·ÅÔÚeaxÖС£Èç¹ûÒª·µ»ØµÄÄÚÈݲ»ÊÇÒ»¸öeaxËùÄÜÈÝÄɵģ¬Win32¡¡API²ÉÓõķ½·¨Ò»°ãÊÇ·µ»ØÒ»¸öÖ¸Õ룬»òÕßÔÚµ÷ÓòÎÊýÖÐÌṩһ¸ö»º³åÇøµØÖ·£¬¸É´à°ÑÊý¾ÝÖ±½Ó·µ»Øµ½»º³åÇøÖÐÈ¥¡£



¡¡
À´Ô´£ºµç×Ó¹¤Òµ³ö°æÉç¡¡×÷ÕߣºÂÞÔƱò¡¡ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡


µÚ3Õ¡¡Ê¹ÓÃMASM


3¡£2¡¡µ÷ÓÃAPI£¨2£©

¡¡¡¡¡¡¡¡
3¡£¡¡º¯ÊýµÄÉùÃ÷

ÔÚµ÷ÓÃAPIº¯ÊýµÄʱºò£¬º¯ÊýÔ­ÐÍÒ²±ØÐëÔ¤ÏÈÉùÃ÷£¬·ñÔò£¬±àÒëÆ÷»á²»ÈÏÕâ¸öº¯Êý¡£invokeαָÁîÒ²ÎÞ·¨¼ì²é²ÎÊý¸öÊý¡£ÉùÃ÷º¯ÊýµÄ¸ñʽÊÇ£º

º¯ÊýÃû¡¡proto¡¡£§¾àÀ룧¡¡£§ÓïÑÔ£§¡¡£§²ÎÊý1£§£ºÊý¾ÝÀàÐÍ£¬£§²ÎÊý2£§£ºÊý¾ÝÀàÐÍ£¬¡­¡­

¾äÖеÄprotoÊǺ¯ÊýÉùÃ÷µÄαָÁ¾àÀë¿ÉÒÔÊÇNEAR£¬FAR£¬NEAR16£¬NEAR32£¬FAR16»òFAR32£¬Win32ÖÐÖ»ÓÐÒ»¸öƽ̹µÄ¶Î£¬ÎÞËùν¾àÀ룬ËùÒÔÔÚ¶¨ÒåʱÊǺöÂԵģ»ÓïÑÔÀàÐ;ÍÊÇ¡¡¡£modelÄÇЩÀàÐÍ£¬Èç¹ûºöÂÔ£¬ÔòʹÓá¡¡£model¶¨ÒåµÄĬÈÏÖµ¡£

ºóÃæ¾ÍÊDzÎÊýµÄÁбíÁË£¬¶ÔWin32»ã±àÀ´ËµÖ»´æÔÚdwordÀàÐ͵IJÎÊý£¬ËùÒÔËùÓвÎÊýµÄÊý¾ÝÀàÐÍÓÀÔ¶ÊÇdword£¬ÁíÍâ¶ÔÓÚ±àÒëÆ÷À´Ëµ£¬ËüÖ»¹ØÐIJÎÊýµÄÊýÁ¿£¬²ÎÊýµÄÃû³ÆÔÚÕâÀïÊÇ¡°ÎÞÓᱵģ¬½öÊÇΪÁ˿ɶÁÐÔ¶øÉèÖõģ¬¿ÉÒÔÊ¡ÂÔµô£¬ËùÒÔÏÂÃæÁ½¾äÏûÏ¢¿òº¯ÊýµÄ¶¨Òåʵ¼ÊÉÏÊÇÒ»ÑùµÄ£º

MessageBox¡¡¡¡Proto¡¡¡¡hWnd£ºdword£»lpText£ºdword£»lpCaption£ºdword£»uType£ºdword

MessageBox¡¡¡¡Proto¡¡¡¡£ºdword£»£ºdword£»£ºdword£»£ºdword

ÔÚWin32»·¾³ÖУ¬ºÍ×Ö·û´®Ïà¹ØµÄAPI¹²ÓÐÁ½À࣬·Ö±ð¶ÔÓ¦Á½¸ö×Ö·û¼¯£ºÒ»ÀàÊÇ´¦Àí¡¡ANSI¡¡×Ö·û¼¯µÄ£¬ÁíÒ»ÀàÊÇ´¦Àí¡¡Unicode¡¡×Ö·û¼¯µÄ¡£Ç°Ò»ÀຯÊýÃû×ÖµÄβ²¿´øÒ»¸ö¡°A¡±×Ö·û£¬´¦ÀíUnicodeµÄÔò´øÒ»¸ö¡°W¡±×Ö·û¡£ÎÒÃDZȽÏÊìϤµÄANSI×Ö·û´®ÊÇÒÔ¡¡NULL¡¡½áβµÄÒ»´®×Ö·ûÊý×飬ÿһ¸öANSI×Ö·ûÕ¼Ò»¸ö×Ö½Ú¿í¡£¶ÔÓÚÅ·ÖÞÓïÑÔÌåϵ£¬ANSI¡¡×Ö·û¼¯ÒÑ×ã¹»ÁË£¬µ«¶ÔÓÚÓгÉǧÉÏÍò¸ö²»Í¬×Ö·ûµÄ¼¸ÖÖ¶«·½ÓïÑÔÌåϵÀ´Ëµ£¬Unicode¡¡×Ö·û¼¯¸üÓÐÓá£Ã¿Ò»¸öUnicode×Ö·ûÕ¼Á½¸ö×ֽڵĿí¶È£¬ÕâÑùÒ»À´¾Í¿ÉÒÔÔÚÒ»¸ö×Ö·û´®ÖÐʹÓÃ65¡¡336¸ö²»Í¬µÄ×Ö·ûÁË¡£

MessageBoxºÍÏÔʾ×Ö·û´®Óйأ¬Í¬ÑùËüÓÐÁ½¸ö°æ±¾£¬ÑϸñµØ˵£¬ÏµÍ³ÖÐÓÐÁ½¸ö¶¨Ò壺

MessageBoxA¡¡¡¡Proto¡¡¡¡hWnd£ºdword£»lpText£ºdword£»lpCaption£ºdword£»uType£ºdword

MessageBoxW¡¡¡¡Proto¡¡¡¡hWnd£ºdword£»lpText£ºdword£»lpCaption£ºdword£»uType£ºdword

ËäÈ»¡¶Microsoft¡¡Win32¡¡Programmer's¡¡Reference¡·ÖÐÖ»ÓÐÒ»¸öMessageBox¶¨Ò壬µ«User32¡£dllÖÐȷȷʵʵûÓÐMessageBox£¬¶øÖ»ÓÐMessageBoxAºÍMessageBoxW£¬ÄÇôΪʲô»¹ÊÇ¿ÉÒÔʹÓÃMessageBoxÄØ£¿Êµ¼ÊÉÏÔÚ³ÌÐòµÄÍ·Îļþuser32¡£incÖÐÓÐÒ»¾ä£º

MessageBox¡¡¡¡¡¡¡¡¡¡¡¡equ¡¡¡¡¡¡¡¡¡¡

Ëü°ÑMessageBox͵Áº»»Öù±ä³ÉÁËMessageBoxA¡£ÔÚÔ´³ÌÐòÖмÌÐøÑØÓÃMessageBoxÊÇ¡¡¡¡ÎªÁ˳ÌÐòµÄ¿É¶ÁÐÔÒÔ¼°±£³ÖºÍÊÖ²áµÄÒ»ÖÂÐÔ£¬µ«¶ÔÓÚ±àÒëÆ÷À´Ëµ£¬Êµ¼ÊÊÇÔÚʹÓÃMessageBoxA¡£

ÓÉÓÚ²¢²»ÊÇÿ¸öWin32ϵͳ¶¼Ö§³ÖWϵÁеÄAPI£¬ÔÚWindows¡¡9xϵÁÐÖУ¬¶ÔUnicodeÊDz»Ö§³ÖµÄ£¬ºÜ¶àµÄAPIÖ»ÓÐANSI°æ±¾£¬Ö»ÓÐWindows¡¡NTϵÁвŶÔUnicodeÍêÈ«Ö§³Ö¡£ÎªÁ˱àдÔÚ¼¸¸öƽ̨ÖÐͨÓõijÌÐò£¬Ò»°ãÓ¦ÓóÌÐò¶¼Ê¹ÓÃANSI°æ±¾µÄAPIº¯Êý¼¯¡£

ΪÁËʹ³ÌÐò¸üÓÐÒÆÖ²ÐÔ£¬ÔÚÔ´³ÌÐòÖÐÒ»°ã²»Ö±½ÓÖ¸Ã÷ʹÓÃUnicode»¹ÊÇANSI°æ±¾£¬¶øÊÇʹÓúê»ã±àÖеÄÌõ¼þ»ã±à¹¦ÄÜÀ´Í³Ò»Ìæ»»£¬ÈçÔÚÔ´³ÌÐòÖÐʹÓÃMessagebox£¬µ«ÔÚÍ·ÎļþÖж¨Ò壺

if¡¡¡¡¡¡¡¡¡¡¡¡UNICODE

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MessageBox¡¡¡¡¡¡¡¡¡¡¡¡equ¡¡¡¡¡¡¡¡¡¡

else

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡MessageBox¡¡¡¡¡¡¡¡¡¡¡¡equ¡¡¡¡¡¡¡¡¡¡

endif

ËùÓÐÉæ¼°°æ±¾ÎÊÌâµÄAPI¶¼¿ÉÒÔ°´´Ë·½·¨¶¨Ò壬ȻºóÔÚÔ´³ÌÐòµÄÍ·²¿Ö¸¶¨UNICODE=1»òUNICODE=0£¬ÖØбàÒëºó¾ÍÄܲúÉú²»Í¬µÄ°æ±¾¡£

4£®includeÓï¾ä

¶ÔÓÚËùÓÐÒªÓõ½µÄAPIº¯Êý£¬ÔÚ³ÌÐòµÄ¿ªÊ¼²¿·Ö¶¼±ØÐëÔ¤ÏÈÉùÃ÷£¬µ«ÕâÒ»¸ö²½ÖèÏÔÈ»ÊDZȽÏÂé·³µÄ£¬ÎªÁ˼ò»¯²Ù×÷£¬¿ÉÒÔ²ÉÓø÷ÖÖÓïÑÔͨÓõĽâ¾ö°ì·¨£¬¾ÍÊÇ°ÑËùÓеÄÉùÃ÷Ô¤ÏÈ·ÅÔÚÒ»¸öÎļþÖУ¬ÔÚÓõ½µÄʱºòÔÙÓÃincludeÓï¾ä°üº¬½øÀ´¡£ÏÖÔڻص½Win32¡¡Hello¡¡World³ÌÐò£¬Õâ¸ö³ÌÐòÓõ½ÁËÁ½¸öAPIº¯Êý£ºMessageBoxºÍExitProcess£¬ËüÃÇ·Ö±ðÔÚUser32¡£dllºÍKernel32¡£dllÖУ¬ÔÚMASM32¹¤¾ß°üÖÐÒѾ­°üÀ¨ÁËËùÓÐDLLµÄAPIº¯ÊýÉùÃ÷ÁÐ±í£¬Ã¿¸öDLL¶ÔÓ¦Îļþ£¬ÔÚÔ´³ÌÐòÖÐֻҪʹÓÃincludeÓï¾ä°üº¬½øÀ´¾Í¿ÉÒÔÁË£º

include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡user32¡£inc

include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡kernel32¡£inc

µ±Óõ½ÆäËûµÄAPIº¯Êýʱ£¬Ö»ÐèÏàÓ¦Ôö¼Ó¶ÔÓ¦µÄincludeÓï¾ä¡£

includeÓï¾ä»¹ÓÃÀ´ÔÚÔ´³ÌÐòÖаüº¬±ðµÄÎļþ£¬µ±¶à¸öÔ´³ÌÐòÓõ½ÏàͬµÄº¯Êý¶¨Òå¡¢³£Á¿¶¨Ò壬ÉõÖÁÔ´´úÂëʱ£¬¿ÉÒÔ°ÑÏàͬµÄ²¿·Öд³ÉÒ»¸öÎļþ£¬È»ºóÔÚ²»Í¬µÄÔ´³ÌÐòÖÐÓÃincludeÓï¾ä°üº¬½øÀ´¡£

±àÒëÆ÷¶ÔincludeÓï¾äµÄ´¦Àí½öÊǼòµ¥µØ°ÑÕâÒ»ÐÐÓÃÖ¸¶¨µÄÎļþÄÚÈÝÌæ»»µô¶øÒÑ¡£

includeÓï¾äµÄÓï·¨ÊÇ£º

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÎļþÃû

»ò¡¡¡¡¡¡¡¡¡¡¡¡¡¡include¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡

µ±Óöµ½Òª°üÀ¨µÄÎļþÃûºÍMASMµÄ¹Ø¼ü×ÖͬÃûµÈ¿ÉÄÜ»áÒýÆð±àÒëÆ÷»ìÏýµÄÇé¿öʱ£¬¿ÉÒÔÓý«ÎļþÃûÀ¨ÆðÀ´¡£

5¡£¡¡includelibÓï¾ä

ÔÚDOS»ã±àÖУ¬Ê¹ÓÃÖжϵ÷ÓÃϵͳ¹¦ÄÜÊDz»±ØÉùÃ÷µÄ£¬´¦ÀíÆ÷×Ô¼ºÖªµÀµ½ÖжÏÏòÁ¿±íÖÐȥȡÖжϵØÖ·¡£ÔÚWin32»ã±àÖÐʹÓÃAPIº¯Êý£¬³ÌÐò±ØÐëÖªµÀµ÷ÓõÄAPIº¯Êý´æÔÚÓÚÄĸöDLLÖУ¬·ñÔò£¬²Ù×÷ϵͳ±ØÐëËÑË÷ϵͳÖдæÔÚµÄËùÓÐDLL£¬²¢ÇÒÎÞ·¨´¦Àí²»Í¬DLLÖеÄͬÃûº¯Êý£¬ÕâÏÔÈ»ÊDz»ÏÖʵµÄ£¬ËùÒÔ£¬±ØÐëÓиöÎļþ°üÀ¨DLL¿âÕýÈ·µÄ¶¨Î»ÐÅÏ¢£¬Õâ¸öÈÎÎñÊÇÓɵ¼Èë¿âÀ´ÊµÏֵġ£

ÔÚʹÓÃÍⲿº¯ÊýµÄʱºò£¬DOSÏÂÓк¯Êý¿âµÄ¸ÅÄÄÇʱµÄº¯Êý¿âʵ¼ÊÉÏÊǾ²Ì¬¿â£¬¾²Ì¬¿âÊÇÒ»×éÒѾ­±àдºÃµÄ´úÂëÄ£¿é£¬ÔÚ³ÌÐòÖпÉÒÔ×ÔÓÉÒýÓã¬ÔÚÔ´³ÌÐò±àÒë³ÉÄ¿±êÎļþ£¬×îºóÒªÁ´½Ó³É¿ÉÖ´ÐÐÎļþµÄʱºò£¬ÓÉlink³ÌÐò´Ó¿âÖÐÕÒ³öÏàÓ¦µÄº¯Êý´úÂ룬һÆðÁ´½Óµ½×îºóµÄ¿ÉÖ´ÐÐÎļþÖС£DOSÏÂCÓïÑԵĺ¯Êý¿â¾ÍÊǵäÐ͵ľ²Ì¬¿â¡£¿âµÄ³öÏÖΪ³ÌÐòÔ±½ÚÊ¡ÁË´óÁ¿µÄ¿ª·¢Ê±¼ä£¬È±µã¾ÍÊÇÿ¸ö¿ÉÖ´ÐÐÎļþÖж¼°üÀ¨ÁËÒªÓõ½µÄÏàͬº¯ÊýµÄ´úÂ룬ռÓÃÁË´óÁ¿µÄ´ÅÅ̿ռ䣬ÔÚÖ´ÐеÄʱºò£¬ÕâЩ´úÂëͬÑùÖظ´Õ¼ÓÃÁ˱¦¹óµÄÄÚ´æ¡£

Win32»·¾³ÖУ¬³ÌÐòÁ´½ÓµÄʱºòÈÔȻҪʹÓú¯Êý¿âÀ´¶¨Î»º¯ÊýÐÅÏ¢£¬Ö»²»¹ýÓÉÓÚº¯Êý´úÂë·ÅÔÚDLLÎļþÖУ¬¿âÎļþÖÐÖ»ÁôÓк¯ÊýµÄ¶¨Î»ÐÅÏ¢ºÍ²ÎÊýÊýÄ¿µÈ¼òµ¥ÐÅÏ¢£¬ÕâÖÖ¿âÎļþ½Ð×öµ¼Èë¿â£¬Ò»¸öDLLÎļþ¶ÔÓ¦Ò»¸öµ¼Èë¿â£¬ÈçUser32¡£dllÎļþÓÃÓÚ±à³ÌµÄµ¼Èë¿âÊÇUser32¡£lib£¬MASM32¹¤¾ß°üÖаüº¬ÁËËùÓÐDLLµÄµ¼Èë¿â¡£

ΪÁ˸æËßÁ´½Ó³ÌÐòʹÓÃÄĸöµ¼Èë¿â£¬Ê¹ÓõÄÓï¾äÊÇ£º

¡¡¡¡¡¡¡¡¡¡¡¡includelib¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¿âÎļþÃû

»ò¡¡¡¡¡¡¡¡includelib¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡

ºÍincludeµÄÓ÷¨Ò»Ñù£¬ÔÚÒª°üÀ¨ÈñàÒëÆ÷»ìÏýµÄÎļþÃûʱ¼Ó·½À¨ºÅ¡£Win32¡¡Hello¡¡world³ÌÐòÓõ½µÄÁ½¸öAPIº¯ÊýMessageBoxºÍExitProcess·Ö±ðÔÚUser32¡£dllºÍKernel32¡£dllÖУ¬ÄÇôÔÚÔ´³ÌÐòʹÓõÄÏàÓ¦Óï¾äΪ£º

includelib¡¡¡¡¡¡¡¡¡¡¡¡user32¡£lib

includelib¡¡¡¡¡¡¡¡¡¡¡¡kernel32¡£lib

ºÍincludeÓï¾äµÄ´¦Àí²»Í¬£¬includelib²»»á°Ñ¡¡¡£libÎļþ²åÈëµ½Ô´³ÌÐòÖУ¬ËüÖ»ÊǸæËßÁ´½ÓÆ÷ÔÚÁ´½ÓµÄʱºòµ½Ö¸¶¨µÄ¿âÎļþÖÐÈ¥ÕÒ¶øÒÑ¡£

3¡£2¡£3¡¡¡¡API²ÎÊýÖеĵÈÖµ¶¨Òå

ÔٻعýÍ·À´¿´ÏÔʾÏûÏ¢¿òµÄÓï¾ä£º

invoke¡¡¡¡MessageBox£»NULL£»offset¡¡szText£»offset¡¡szCaption£»MB_OK

ÔÚuTypeÕâ¸ö²ÎÊýÖÐʹÓÃÁËMB_OK£¬Õâ¸öMB_OKÊÇʲôÒâ˼ÄØ£¬ÏÈÀ´¿´¡¶Microsoft¡¡Win32¡¡Programmer's¡¡Reference¡·ÖеÄ˵Ã÷£º

uType¡¡¡ª¡ª¡¡¶¨Òå¶Ô»°¿òµÄÀàÐÍ£¬Õ
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
δÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡