{"id":370,"date":"2020-06-08T16:09:10","date_gmt":"2020-06-08T08:09:10","guid":{"rendered":"http:\/\/123.57.142.208\/?p=370"},"modified":"2020-06-08T16:09:10","modified_gmt":"2020-06-08T08:09:10","slug":"%e5%ad%a6%e4%b9%a0%e5%89%8d%e7%ab%af%e5%bc%80%e5%8f%91%e4%b9%8b%e5%89%8d%e6%88%91%e4%bb%ac%e9%9c%80%e8%a6%81%e7%9f%a5%e9%81%93%e7%9a%84","status":"publish","type":"post","link":"http:\/\/43.142.23.155\/?p=370","title":{"rendered":"\u5b66\u4e60Windows\u5f00\u53d1\u4e4b\u524d\u6211\u4eec\u9700\u8981\u77e5\u9053\u7684"},"content":{"rendered":"\n<p>\u6700\u8fd1\u56e0\u4e3a\u51e0\u4e2a\u9879\u76ee\u548c\u5b66\u6821\u7684\u4f17\u591a\u5b9e\u9a8c\u7684\u539f\u56e0\uff0c\u771f\u7684\u662f\u8d8a\u66f4\u8d8a\u6162\uff0c\u4e00\u65b9\u9762\u4e5f\u662f\u81ea\u5df1\u5f00\u59cb\u53d8\u61d2\uff0c\u518d\u8005\u65f6\u95f4\u5b89\u6392\u7684\u4e0d\u592a\u79d1\u5b66\u5408\u7406\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u7684\u722c\u866b\u76f8\u5173\u535a\u6587\u53ef\u80fd\u8981\u6682\u65f6\u6401\u7f6e\u4e00\u4e24\u4e2a\u6708\uff0c\u7531\u4e8e\u75ab\u60c5\u7684\u539f\u56e0\uff0c\u4e92\u8054\u7f51+\u5927\u8d5b\u7684\u51c6\u5907\u65f6\u95f4\u53d8\u5f97\u8d85\u7ea7\u7d27\uff0c\u6211\u5fc5\u987b\u627e\u65f6\u95f4\u5b8c\u6210win\u5f00\u53d1\u7684\u7cfb\u7edf\u5b66\u4e60\u5e76\u5b89\u6392\u597d\u671f\u672b\u5b9e\u9a8c\u548c\u590d\u4e60\uff0c\u4e0d\u8fc7\u653e\u5fc3\u722c\u866b\u76f8\u5173\u5185\u5bb9\u7684\u5176\u5b9e\u89c4\u5212\u5df2\u7ecf\u51fa\u6765\u4e86\u5c31\u662f\u6ca1\u7801\u5b57\uff08\u6bd5\u7adf\u662f\u4ee5\u524d\u5b66\u5b8c\u7684\u4e86\uff09\u3002<\/p>\n\n\n\n<p>\u6211\u73b0\u5728\u89c9\u5f97\u6211\u603b\u7ed3\u4e86\u534a\u5929\u7684\u5185\u5bb9\u8ddf\u9879\u76ee\u53ef\u80fd\u5173\u7cfb\u4e0d\u592a\u5927&#8230;<\/p>\n\n\n\n<p>            <\/p>\n\n\n\n<p>           <\/p>\n\n\n\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u6211\u4e0d\u5e9f\u8bdd\u4e86\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n\n\n\n<p>         <\/p>\n\n\n\n<p>       <\/p>\n\n\n\n<p>         <\/p>\n\n\n\n<p>Win32 API\uff08Application Programming Interface\uff09<\/p>\n\n\n\n<p>Win32 API\u53ef\u8ba4\u4e3a\u662f\u4e00\u4e2a\u7a0b\u5e8f\u5e93\uff0c\u63d0\u4f9b\u5404\u5f0f\u5404\u6837\u7684\u4e0ewindows\u7cfb\u7edf\u670d\u52a1\u6709\u5173\u7684\u51fd\u6570\u3002<\/p>\n\n\n\n<p>Win32 API\u662f\u6700\u5e95\u5c42\u7684\u670d\u52a1\uff0c\u53ef\u8c03\u7528Windows\u7684\u5404\u79cd\u670d\u52a1\u3002<\/p>\n\n\n\n<p>\u901a\u5e38\u6240\u8bf4\u7684SDK\u7f16\u7a0b\u5c31\u662f\u76f4\u63a5\u8c03\u7528API\u51fd\u6570\u8fdb\u884c\u7f16\u7a0b\u3002<\/p>\n\n\n\n<p>Win32 API\u662f\u6307\u7f16\u523632\u4f4d\u5e94\u7528\u7a0b\u5e8f\u65f6\u7528\u7684\u4e00\u7ec4\u51fd\u6570\u3001\u7ed3\u6784\u3001\u5b8f\u5b9a\u4e49\u3002\u5728Win32\u7684\u73af\u5883\u4e0b\uff0c\u4efb\u4f55\u8bed\u8a00\u90fd\u662f\u5efa\u7acb\u5728Win32 API\u57fa\u7840\u4e0a\u7684\u3002C#\u7b49\u8f6f\u4ef6API\u9690\u85cf\u7684\u8f83\u6df1\u3002<\/p>\n\n\n\n<p>\u5927\u591a\u6570API\u4f4d\u4e8e\u4e09\u4e2a\u6838\u5fc3\u7684DLL\u4e2d<\/p>\n\n\n\n<p>kernel32.dll\u3001user32.dll\u3001GDI32.dll<\/p>\n\n\n\n<p>\u91c7\u7528\u5176\u5f00\u53d1windows\u5e94\u7528\u7a0b\u5e8f\u8fc7\u4e8e\u7e41\u7410\u3002<\/p>\n\n\n\n<p>API&amp;MFC<\/p>\n\n\n\n<p>1\u3001kernel<\/p>\n\n\n\n<p>\u5728Win32\u4e2d\u5e93\u540d\u4e3aKERNEL32.DLL,\u4e3b\u8981\u7528\u4e8e\u4ea7\u751f\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u4e4b\u95f4\u7684\u5173\u8054\u3002<\/p>\n\n\n\n<p>\u7a0b\u5e8f\u52a0\u8f7d<\/p>\n\n\n\n<p>\u4e0a\u4e0b\u6587\u9009\u62e9<\/p>\n\n\n\n<p>\u6587\u4ef6\u8f93\u5165\u8f93\u51fa<\/p>\n\n\n\n<p>\u5185\u5b58\u7ba1\u7406<\/p>\n\n\n\n<p>\u4f8b\u5982\uff1aGlobalMemoryStatus\u51fd\u6570\u5c31\u662f\u5305\u62ec\u5f53\u524d\u7269\u7406\u5185\u5b58\u53ca\u865a\u62df\u5185\u5b58\u7684\u4f7f\u7528\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>2\u3001user<\/p>\n\n\n\n<p>\u8fd9\u4e2a\u7c7b\u5e93\u5728Win32\u4e2d\u540d\u53ebUSER32.DLL<\/p>\n\n\n\n<p>\u5b83\u5141\u8bb8\u7ba1\u7406\u5168\u90e8\u7684\u7528\u6237\u63a5\u53e3\u3002\u4f8b\u5982<\/p>\n\n\n\n<p>\u7a97\u53e3<\/p>\n\n\n\n<p>\u83dc\u5355<\/p>\n\n\n\n<p>\u5bf9\u8bdd\u6846<\/p>\n\n\n\n<p>\u56fe\u6807\u7b49\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0cDrawIcon\u51fd\u6570\u5c06\u5728\u6307\u5b9a\u7684\u8bbe\u5907\u5173\u8054\u4e0a\u201c\u753b\u201d\u51fa\u56fe\u6807\u6216\u8005\u9f20\u6807\u3002<\/p>\n\n\n\n<p>3\u3001GDI(Graphical Device Interface)<\/p>\n\n\n\n<p>\u5b83\u5728Win32\u4e2d\u7684\u5e93\u540d\u4e3aGDI32.dll\uff0c\u5b83\u662f\u56fe\u5f62\u8f93\u51fa\u5e93\uff0c\u4f7f\u7528GDI Windows &#8220;\u753b&#8221;\u51fa\u7a97\u53e3\u3001\u83dc\u5355\u4ee5\u53ca\u5bf9\u8bdd\u6846\u7b49\uff1b<\/p>\n\n\n\n<p>\u5b83\u80fd\u521b\u5efa\u56fe\u5f62\u8f93\u51fa<\/p>\n\n\n\n<p>\u5b83\u4e5f\u80fd\u4fdd\u5b58\u56fe\u5f62\u6587\u4ef6\u3002<\/p>\n\n\n\n<p>\u4f8b\u5982\uff0cCreateBitmap \u51fd\u6570\u5c31\u80fd\u901a\u8fc7\u6307\u5b9a\u7684\u957f\u3001\u5bbd\u3001\u989c\u8272\u521b\u5efa\u4e00\u4e2a\u4f4d\u56fe\u3002<\/p>\n\n\n\n<p>4\u3001API&amp;MFC<\/p>\n\n\n\n<p>API\uff1a\u4e00\u5957\u7528\u6765\u63a7\u5236Windows\u7684\u5404\u4e2a\u90e8\u4ef6(\u4ece\u684c\u9762\u7684\u5916\u89c2\u5230\u4e3a\u4e00\u4e2a\u65b0\u8fdb\u7a0b\u5206\u914d\u7684\u5185\u5b58)\u7684\u5916\u89c2\u548c\u884c\u4e3a\u7684\u4e00\u5957\u9884\u5148\u5b9a\u4e49\u7684Windows\u51fd\u6570\u3002<\/p>\n\n\n\n<p>MFC\uff1a\u662f\u5bf9Windows API\u7684\u5c01\u88c5\uff0c\u662fWin API\u4e0eC++\u7684\u7ed3\u5408\uff0cMFC\u5c31\u662f\u6302\u5728\u5b83\u4e4b\u4e0a\u7684\u4e00\u4e2a\u8f85\u52a9\u8f6f\u4ef6\u5f00\u53d1\u5305\u3002<\/p>\n\n\n\n<p>MFC\u7684\u4e3b\u5305\u542b\u6587\u4ef6\u4e3a&#8221;Afxwin.h&#8221;<\/p>\n\n\n\n<p>API\u7684\u4e3b\u5305\u542b\u6587\u4ef6\u4e3a&#8221;windows.h&#8221;<\/p>\n\n\n\n<p>API \u51fd\u6570\u7684\u8c03\u7528\u65b9\u6cd5<\/p>\n\n\n\n<p>1\u3001C++\u8c03\u7528\u8fc7\u7a0b<\/p>\n\n\n\n<p>(1)\u5305\u542b\u8981\u8c03\u7528\u51fd\u6570\u7684\u58f0\u660e\u6587\u4ef6<\/p>\n\n\n\n<p>windows.h\u5305\u542b\u5176\u4ed6\u5934\u6587\u4ef6<\/p>\n\n\n\n<p>windef.h\u57fa\u672c\u7c7b\u578b\u5b9a\u4e49<\/p>\n\n\n\n<p>winnt.h\u652f\u6301Unicode\u7684\u7c7b\u578b\u5b9a\u4e49<\/p>\n\n\n\n<p>winbase.h\u5185\u6838\u51fd\u6570<\/p>\n\n\n\n<p>winuser.h\u7528\u6237\u63a5\u53e3\u51fd\u6570<\/p>\n\n\n\n<p>wingdi.h\u56fe\u5f62\u8bbe\u5907\u63a5\u53e3\u51fd\u6570<\/p>\n\n\n\n<p>winsock.h\u7f51\u7edc\u7f16\u7a0b\u51fd\u6570<\/p>\n\n\n\n<p>(2)\u8fde\u63a5\u5230\u6307\u5b9a\u7684\u5e93\u6587\u4ef6<\/p>\n\n\n\n<p>kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib<\/p>\n\n\n\n<p>\u663e\u5f0f\u8bbe\u7f6e #pragma comment(lib,&#8221;WS2_32.lib&#8221;)<\/p>\n\n\n\n<p>(3)\u5728API\u51fd\u6570\u524d\u52a0&#8221;::&#8221;\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u5168\u5c40\u51fd\u6570\uff0c\u4ee5\u4e0eC++\u7c7b\u7684\u6210\u5458\u51fd\u6570\u533a\u5206\u3002<\/p>\n\n\n\n<p>\u8c03\u7528API\u4f8b\u5b50\uff08C++\uff09<\/p>\n\n\n\n<p>#include &#8220;stdafx.h&#8221;&nbsp;&nbsp;&nbsp;\/\/ \u8fd9\u662fVC\u81ea\u52a8\u6dfb\u52a0\u7684\u5934\u6587\u4ef6\uff0c\u4e3b\u8981\u662f\u52a0\u5feb\u7f16\u8bd1\u901f\u5ea6#include &lt;windows.h&gt;&nbsp;&nbsp;\/\/ \u5305\u542bMessageBox\u51fd\u6570\u58f0\u660e\u7684\u5934\u6587\u4ef6 int main(int argc,char *argv[]){&nbsp;\/\/ \u8c03\u7528API\u51fd\u6570MessageBox&nbsp;int nSelect = ::MessageBox(&nbsp;NULL,&nbsp;&#8220;Hello,Windows&#8221;,&nbsp;&#8220;Greeting&#8221;,&nbsp;MB_OKCANCEL);&nbsp;&nbsp;if(nSelect == IDOK)&nbsp;&nbsp;printf(&#8220;\u7528\u6237\u9009\u62e9\u4e86\u201c\u786e\u5b9a&#8221;\u6309\u94ae\\n&#8221;);&nbsp;else&nbsp;&nbsp;printf(&#8220;\u7528\u6237\u9009\u62e9\u4e86\u201c\u53d6\u6d88&#8221;\u6309\u94ae\\n&#8221;);&nbsp;return 0;}<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u56e0\u4e3a\u51e0\u4e2a\u9879\u76ee\u548c\u5b66\u6821\u7684\u4f17\u591a\u5b9e\u9a8c\u7684\u539f\u56e0\uff0c\u771f\u7684\u662f\u8d8a\u66f4\u8d8a\u6162\uff0c\u4e00\u65b9\u9762\u4e5f\u662f\u81ea\u5df1\u5f00\u59cb\u53d8\u61d2\uff0c\u518d\u8005\u65f6\u95f4\u5b89\u6392\u7684\u4e0d\u592a\u79d1\u5b66\u5408\u7406\u3002 \u6211\u4eec\u7684\u722c\u866b\u76f8\u5173\u535a\u6587\u53ef\u80fd\u8981\u6682\u65f6\u6401\u7f6e\u4e00\u4e24\u4e2a\u6708\uff0c\u7531\u4e8e\u75ab\u60c5\u7684\u539f\u56e0\uff0c\u4e92\u8054\u7f51+\u5927\u8d5b\u7684\u51c6\u5907\u65f6\u95f4\u53d8\u5f97\u8d85\u7ea7\u7d27&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-370","post","type-post","status-publish","format-standard","hentry","category-windows"],"_links":{"self":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/370","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=370"}],"version-history":[{"count":0,"href":"http:\/\/43.142.23.155\/index.php?rest_route=\/wp\/v2\/posts\/370\/revisions"}],"wp:attachment":[{"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=370"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/43.142.23.155\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}