{"id":14336,"date":"2025-04-18T21:08:24","date_gmt":"2025-04-18T13:08:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/14336.html"},"modified":"2025-04-18T21:08:24","modified_gmt":"2025-04-18T13:08:24","slug":"c%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ad%a6%e4%b9%a0%e4%bb%8e%e9%9b%b6%e5%bc%80%e5%a7%8b%ef%bc%9a%e7%ac%ac%e4%b8%80%e6%9c%9f%e4%bd%bf%e7%94%a8windows%e7%9a%84%e5%bb%ba%e8%ae%aeapi%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/14336.html","title":{"rendered":"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1"},"content":{"rendered":"<p>\u6211\u4eca\u5929\u5199\u7684\u662f\u901a\u8fc7windows\u7684api\u642d\u5efa\u754c\u9762\u548c\u6548\u679c\u7684\u5b9e\u73b0 \u4ee3\u7801\u5206\u4e3a\u670d\u52a1\u5668\u7aef\u7684\u4ee3\u7801&#xff0c;\u5ba2\u6237\u7aef\u7684\u4ee3\u7801<\/p>\n<p>\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4ee3\u7801\u7ed3\u6784\u5206\u4e3a 1.\u754c\u9762\u7ed8\u5236 2.\u7f51\u7edc\u901a\u4fe1\u6a21\u5757 3.\u591a\u7ebf\u7a0b\u7ba1\u7406\u6a21\u5757 4.\u6d88\u606f\u5904\u7406\u6a21\u5757<\/p>\n<p>\/\/\u5ba2\u6237\u7aef\u4ee3\u7801<br \/>\n#include &lt;Windows.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;tchar.h&gt;<br \/>\n#include &lt;stdio.h&gt;<br \/>\n#include &lt;Commctrl.h&gt;<br \/>\n#pragma comment(lib,&#034;wsock32.lib&#034;)<br \/>\n#include&lt;Windows.h&gt;<br \/>\n#include&lt;iostream&gt;<br \/>\n#include&lt;string&gt;<br \/>\n#define ID_STATE 1<br \/>\n#define ID_TEXTLIST  2<br \/>\n#define ID_SENDTEXT 3<br \/>\n#define ID_CLOSE 4<br \/>\n#define ID_SEND 5<br \/>\n#define ID_CONNECT 6<br \/>\n#define ID_CLOSELINK 7<br \/>\n#define ID_IP 8<br \/>\n#define ID_CLIENTLIST 9<\/p>\n<p>\/\/\u5168\u5c40\u53d8\u91cf<br \/>\nTCHAR szClassName[] &#061; TEXT(&#034;MyWindowClass&#034;);  \/\/\u7a97\u53e3\u7c7b\u540d<br \/>\nTCHAR szWindowName[] &#061; TEXT(&#034;\u7f51\u7edc\u804a\u5929\u5ba4&#8212;-\u5ba2\u6237\u7aef&#034;); \/\/\u7a97\u53e3\u6807\u9898\u540d<\/p>\n<p>HWND hdlg;<br \/>\nHWND hwnd,hSendText,hSendBtn,hTextList,hCloseBtn,hConnectBtn,hIpInput,hState,hCloseLinkBtn,hClientList,hSendTip;<br \/>\nWSADATA wsaData;<br \/>\nSOCKET Remote;<br \/>\nsockaddr_in RemoteAdd;<br \/>\nHANDLE ThdConnect,ThdRecv,ThdSend; \/\/\u4e09\u4e2a\u7ebf\u7a0b\u53e5\u67c4<br \/>\nSYSTEMTIME sysTime;\/\/\u4fdd\u5b58\u672c\u5730\u65f6\u95f4\u4fe1\u606f<br \/>\nbool isClose&#061;true;\/\/\u5224\u65ad\u7a0b\u5e8f\u662f\u5426\u7ed3\u675f<br \/>\n\/\/HMENU hmenu,hpopup;<br \/>\nchar sendToIp[20]&#061;&#034;\u6240\u6709\u4eba&#034;;\/\/\u4fdd\u5b58\u63a5\u6536\u6d88\u606f\u7684\u5ba2\u6237\u7aefip<br \/>\n\/\/\u51fd\u6570\u58f0\u660e<br \/>\nATOMMyRegisterClass(HINSTANCE hInstance);      \/\/ \u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u51fd\u6570<br \/>\nBOOLInitInstance(HINSTANCE, int);              \/\/ \u521d\u59cb\u5316\u51fd\u6570&#xff08;\u521b\u5efa\u5e76\u663e\u793a\u7a97\u53e3&#xff09;<br \/>\nLRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);       \/\/ \u7a97\u53e3\u51fd\u6570<br \/>\nDWORD WINAPI ThreadConnect(LPVOID p);<br \/>\nDWORD WINAPI ThreadRecv(LPVOID p);<br \/>\nDWORD WINAPI ThreadSend(LPVOID p);<br \/>\n\/\/****\u5165\u53e3\u51fd\u6570*************************************<br \/>\nint WINAPI WinMain(HINSTANCE hInstance,<br \/>\n   HINSTANCE hPrevInstance,<br \/>\n   LPSTR     lpCmdLine,<br \/>\n   int       nCmdShow)<br \/>\n{<br \/>\nMSG msg;<\/p>\n<p>\/\/\u8fd0\u884c\u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u7684\u51fd\u6570<br \/>\nMyRegisterClass(hInstance);<\/p>\n<p>\/\/\u6267\u884c\u5e94\u7528\u7a0b\u5e8f\u521d\u59cb\u5316<br \/>\nif (!InitInstance (hInstance, nCmdShow))<br \/>\n{<br \/>\nreturn FALSE;<br \/>\n}<\/p>\n<p>\/\/\u4e3b\u6d88\u606f\u5faa\u73af<br \/>\nwhile(GetMessage(&amp;msg, NULL, 0, 0))   \/\/\u4ece\u6d88\u606f\u961f\u5217\u4e2d\u53d6\u51fa\u6d88\u606f<br \/>\n{<br \/>\nTranslateMessage(&amp;msg);   \/\/ \u5c06\u6309\u952e\u6d88\u606f\u8f6c\u6362\u4e3a\u5b57\u7b26\u6d88\u606f<br \/>\nDispatchMessage(&amp;msg);    \/\/ \u5c06\u6d88\u606f\u53d1\u9001\u5230\u76f8\u5e94\u7684\u7a97\u53e3\u51fd\u6570<br \/>\n}<br \/>\nShowWindow(hwnd,nCmdShow);<br \/>\nUpdateWindow(hwnd);<br \/>\nreturn (int)msg.wParam;   \/\/ \u5f53GetMessage\u8fd4\u56de0\u65f6\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u5c06MSG\u7684wParam\u53c2\u6570\u8fd4\u56de\u64cd\u4f5c\u7cfb\u7edf<br \/>\n}<\/p>\n<p>\/\/****\u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u51fd\u6570*************************<br \/>\nATOM MyRegisterClass(HINSTANCE hInstance)<br \/>\n{<br \/>\nWNDCLASS wc;<\/p>\n<p>\/\/ \u7528\u63cf\u8ff0\u4e3b\u7a97\u53e3\u7684\u53c2\u6570\u586b\u5145WNDCLASS\u7ed3\u6784<br \/>\nwc.style &#061; CS_HREDRAW|CS_VREDRAW;   \/\/ \u6307\u5b9a\u5982\u679c\u7a97\u53e3\u5927\u5c0f\u6539\u53d8\u5c31\u91cd\u7ed8<br \/>\nwc.lpfnWndProc &#061; WndProc;        \/\/ \u7a97\u53e3\u51fd\u6570\u6307\u9488<br \/>\nwc.cbClsExtra &#061; 0;            \/\/ \u6ca1\u6709\u989d\u5916\u7684\u7c7b\u5185\u5b58<br \/>\nwc.cbWndExtra &#061; 0;            \/\/ \u6ca1\u6709\u989d\u5916\u7684\u7a97\u53e3\u5185\u5b58<br \/>\nwc.hInstance &#061; hInstance;    \/\/ \u5b9e\u4f8b\u53e5\u67c4<br \/>\nwc.hIcon &#061; LoadIcon(NULL, IDI_APPLICATION);                \/\/ \u4f7f\u7528\u9884\u5b9a\u4e49\u56fe\u6807<br \/>\nwc.hCursor &#061; LoadCursor(NULL, IDC_ARROW);            \/\/ \u4f7f\u7528\u9884\u5b9a\u4e49\u5149\u6807<br \/>\nwc.hbrBackground &#061; (HBRUSH)GetStockObject(WHITE_BRUSH);    \/\/ \u4f7f\u7528\u767d\u8272\u80cc\u666f\u753b\u5237<br \/>\nwc.lpszMenuName &#061; NULL;                                \/\/ \u4e0d\u6307\u5b9a\u83dc\u5355<br \/>\nwc.lpszClassName &#061; szClassName ;                        \/\/ \u7a97\u53e3\u7c7b\u7684\u540d\u79f0<\/p>\n<p>return RegisterClass(&amp;wc);          \/\/\u6ce8\u518c\u7a97\u53e3\u7c7b&#xff0c;\u5982\u679c\u6210\u529f\u5219\u8fd4\u56de\u4e00\u4e2aatom\u503c&#xff0c;\u5931\u8d25\u5219\u8fd4\u56de0<br \/>\n}<\/p>\n<p>\/\/****\u521d\u59cb\u5316\u51fd\u6570************************************<br \/>\nBOOL InitInstance(HINSTANCE hInstance, int nCmdShow)<br \/>\n{<\/p>\n<p>\/\/\u53e5\u67c4\u662f\u7a97\u53e3\u7684\u6807\u8bc6&#xff0c;\u8bbe\u7f6e\u63a7\u4ef6\u90fd\u8981\u6307\u5b9a\u53e5\u67c4\u4e0a<br \/>\nhwnd &#061; CreateWindow(szClassName, szWindowName, WS_OVERLAPPEDWINDOW,<br \/>\n300,100, 700, 550, NULL, NULL, hInstance, NULL);<br \/>\nif (!hwnd)<br \/>\n{<br \/>\nreturn FALSE;<br \/>\n}<br \/>\nShowWindow(hwnd,nCmdShow);<br \/>\nUpdateWindow(hwnd);<br \/>\n\/\/\u8fde\u63a5\u72b6\u6001<br \/>\nhState&#061;CreateWindowA(&#034;static&#034;,&#034;\u8fde\u63a5\u72b6\u6001:\u7b49\u5f85\u8fde\u63a5&#034;,WS_VISIBLE|WS_CHILD,<br \/>\n10,10,150,20,hwnd,(HMENU)1,hInstance,NULL);<\/p>\n<p>\/\/\u63d0\u793a<br \/>\nCreateWindowA(&#034;static&#034;,&#034;\u8bf7\u9009\u62e9\u53d1\u9001\u5bf9\u8c61&#034;,WS_VISIBLE|WS_CHILD,<br \/>\n480,10,120,20,hwnd,(HMENU)1,hInstance,NULL);<br \/>\n\/\/\u5386\u53f2\u8bb0\u5f55<br \/>\nhTextList&#061;CreateWindowA(&#034;edit&#034;,NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|<br \/>\nES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL,<br \/>\n10,30,450,300,hwnd,(HMENU)2,hInstance,NULL);<br \/>\n\/\/\u53d1\u9001\u6587\u672c\u6846<br \/>\nhSendText&#061;CreateWindowA(&#034;edit&#034;,NULL,WS_CHILD|WS_VISIBLE|WS_BORDER|<br \/>\nES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL,<br \/>\n10,360,450,100,hwnd,(HMENU)3,hInstance,NULL);<br \/>\n\/\/&#034;\u5173\u95ed&#034;\u6309\u94ae<br \/>\nhCloseBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u5173\u95ed&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,<br \/>\n300,465,50,25,hwnd,(HMENU)4,hInstance,NULL);<br \/>\n\/\/&#034;\u53d1\u9001&#034;\u6309\u94ae<br \/>\nhSendBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u53d1\u9001&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_DISABLED,<br \/>\n390,465,50,25,hwnd,(HMENU)5,hInstance,NULL);<br \/>\n\/\/&#034;\u8fde\u63a5&#034;\u6309\u94ae<br \/>\nhConnectBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u8fde\u63a5&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,<br \/>\n300,333,50,25,hwnd,(HMENU)6,hInstance,NULL);<br \/>\n\/\/ip\u63d0\u793a\u6846<br \/>\nCreateWindowA(&#034;static&#034;,&#034;\u670d\u52a1\u5668IP&#034;,WS_VISIBLE|WS_CHILD ,<br \/>\n10,335,60,20,hwnd,NULL,hInstance,NULL);<br \/>\n\/\/&#034;\u65ad\u5f00&#034;\u6309\u94ae<br \/>\nhCloseLinkBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u65ad\u5f00&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_DISABLED,<br \/>\n400,333,50,25,hwnd,(HMENU)7,hInstance,NULL);<br \/>\n\/\/ip\u6846<br \/>\nhIpInput&#061;CreateWindowA(&#034;edit&#034;,&#034;&#034;,WS_CHILD|WS_VISIBLE|WS_BORDER,<br \/>\n90,335,100,20,hwnd,(HMENU)8,hInstance,NULL);<\/p>\n<p>\/\/\u5217\u8868<\/p>\n<p>hClientList&#061;CreateWindowA(&#034;listbox&#034;,&#034;\u5217\u8868&#034;,WS_CHILD|WS_VISIBLE|LBS_HASSTRINGS|LBS_NOTIFY ,<br \/>\n480,35,150,305,hwnd,(HMENU)9,hInstance,NULL);<\/p>\n<p>hSendTip&#061;CreateWindowA(&#034;static&#034;,&#034;\u5f53\u524d\u53d1\u9001\u76ee\u6807:\u6240\u6709\u4eba&#034;,WS_VISIBLE|WS_CHILD,<br \/>\n10,467,230,20,hwnd,NULL,hInstance,NULL);<\/p>\n<p>\/\/\u521b\u5efa\u83dc\u5355\u9879<br \/>\n\/\/hmenu&#061;CreateMenu() ;<br \/>\n\/\/hpopup&#061;CreatePopupMenu();<br \/>\n\/\/AppendMenu(hpopup,MF_STRING,10,TEXT(&#034;&amp;\u53d1\u9001\u7ed9\u6240\u6709\u4eba&#034;));<br \/>\n\/\/AppendMenu(hpopup,MF_STRING,11,TEXT(&#034;&amp;\u4e0eTA\u79c1\u804a&#034;));<br \/>\n\/\/AppendMenu(hpopup,MF_STRING,12,TEXT(&#034;&amp;\u53d6\u6d88&#034;));<br \/>\n\/\/AppendMenu(hmenu,MF_POPUP,(int)hpopup,NULL);<\/p>\n<p>SetWindowTextA(hIpInput,&#034;127.0.0.1&#034;);<br \/>\nreturn TRUE;<br \/>\n}<\/p>\n<p>\/\/****\u7a97\u53e3\u51fd\u6570**************************************<br \/>\nLRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)\/\/\u53e5\u67c4 \u6d88\u606f  \u4f20\u9012\u6574\u6570,\u53e5\u67c4\u6216\u6807\u5fd7\u4f4d  \u4f20\u9012\u6574\u6570,\u6307\u9488\u6216\u7ed3\u6784\u4f53\u4fe1\u606f<br \/>\n{<br \/>\nHDC hdc;<br \/>\nPAINTSTRUCT ps;<br \/>\nstatic char ipAdd[20];<br \/>\nPOINT point;<br \/>\nstatic HBITMAP hBitmap;<br \/>\nstatic BITMAP bg;<br \/>\nstatic HDC hdcMem;<br \/>\nswitch (message)<br \/>\n{<br \/>\ncase WM_PAINT:<br \/>\nhdc &#061; BeginPaint (hwnd, &amp;ps) ;<br \/>\nSelectObject(hdcMem,hBitmap);<br \/>\nBitBlt(hdc,0,0,bg.bmWidth,bg.bmHeight,hdcMem,0,0,SRCCOPY);<br \/>\nEndPaint(hwnd, &amp;ps);<br \/>\nreturn 0;<br \/>\ncase WM_CREATE:<br \/>\n{<br \/>\n\/\/\u521d\u59cb\u5316<br \/>\nWSAStartup(MAKEWORD(2,0),&amp;wsaData);<br \/>\n\/\/RemoteAdd.sin_family&#061;AF_INET;<br \/>\n\/\/RemoteAdd.sin_port&#061;htons(12057);<br \/>\n\/\/Remote&#061;socket(AF_INET,SOCK_STREAM,0);<br \/>\nhBitmap&#061;(HBITMAP)LoadImage(NULL,TEXT(&#034;pic\\\\\\\\bg.BMP&#034;),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);\/\/\u80cc\u666f\u56fe<br \/>\nGetObject(hBitmap,sizeof(BITMAP),&amp;bg);<br \/>\nhdc&#061;GetDC(hwnd);<br \/>\nhdcMem&#061;CreateCompatibleDC(hdc);<br \/>\nReleaseDC(hwnd,hdc);<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase WM_MOUSEMOVE:\/\/\u9f20\u6807\u79fb\u52a8\u6d88\u606f<br \/>\npoint.x&#061;LOWORD(lParam);\/\/\u6c34\u5e73\u65b9\u5411\u5750\u6807    HIWORD\u76f8\u5f53\u4e8e\u8981\u9ad8\u76848\u4f4d\u6570\u636e LOWORD\u8981\u6570\u636e\u4f4e\u7684\u516b\u4f4d<br \/>\npoint.y&#061;HIWORD(lParam);\/\/\u5782\u76f4\u65b9\u5411\u5750\u6807<br \/>\nreturn 0;<br \/>\ncase WM_COMMAND:\/\/\u7528\u6237\u4e0e\u7ec4\u4ef6\u4ea4\u4e92\u7684\u4fe1\u53f7<br \/>\nif ( HIWORD(wParam)&#061;&#061;LBN_DBLCLK )<br \/>\n{<br \/>\nint i&#061;SendMessageA(hClientList,LB_GETCURSEL,0,0);\/\/\u5f97\u5230\u9009\u62e9\u9879\u7684\u7d22\u5f15<br \/>\nSendMessageA(hClientList,LB_GETTEXT,i,(LPARAM)sendToIp);\/\/\u6839\u636e\u7d22\u5f15\u5f97\u5230\u5185\u5bb9<br \/>\nchar a[30];<br \/>\nstrcpy(a,&#034;\u5f53\u524d\u53d1\u9001\u76ee\u6807: &#034;);<br \/>\nstrcat(a,sendToIp);<br \/>\nSetWindowTextA(hSendTip,a);\/\/\u63d0\u793a\u53d1\u9001\u5bf9\u8c61<br \/>\n}<br \/>\nswitch(LOWORD(wParam))<br \/>\n{<br \/>\ncase ID_CONNECT:<br \/>\n{<br \/>\nGetWindowTextA(hIpInput,ipAdd,21);<br \/>\nEnableWindow(hConnectBtn,0);<br \/>\nif ( strlen(ipAdd)&lt;8)<br \/>\n{<br \/>\nMessageBoxA(hwnd,&#034;IP\u5730\u5740\u8f93\u5165\u9519\u8bef,\u8bf7\u91cd\u65b0\u8f93\u5165.&#034;,&#034;\u9519\u8bef&#034;,MB_OK);<br \/>\nreturn 0;<br \/>\n}<br \/>\nRemoteAdd.sin_addr.S_un.S_addr&#061;inet_addr(ipAdd);<br \/>\nThdConnect&#061;CreateThread(NULL,NULL,ThreadConnect,NULL,NULL,NULL);\/\/\u521b\u5efa\u8fde\u63a5\u7684\u7ebf\u7a0b<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase ID_CLOSELINK:<br \/>\n{<\/p>\n<p>isClose&#061;true;<br \/>\nchar cBuff[2]&#061;{&#039;q&#039;,&#039;#&#039;};<br \/>\nsend(Remote,cBuff,3,0);<br \/>\nEnableWindow(hConnectBtn,1);\/\/\u8ba9\u63a7\u4ef6\u663e\u793a<br \/>\nEnableWindow(hCloseLinkBtn,0);\/\/\u8ba9\u63a7\u4ef6\u5173\u95ed<br \/>\nSetWindowTextA(hState,&#034;\u8fde\u63a5\u72b6\u6001:\u672a\u8fde\u63a5&#034;);<br \/>\nEnableWindow(hSendBtn,0);<br \/>\nEnableWindow(hIpInput,1);<br \/>\nSendMessageA(hClientList,LB_RESETCONTENT ,0,0);<br \/>\n\/\/WaitForSingleObject(&amp;ThdRecv,INFINITE);<br \/>\n\/\/closesocket(Remote);<br \/>\n\/\/WSACleanup();<\/p>\n<p>}<br \/>\nreturn 0;<br \/>\ncase ID_CLOSE:<br \/>\n{<br \/>\nchar cBuff[2]&#061;{&#039;q&#039;,&#039;#&#039;};<br \/>\nsend(Remote,cBuff,3,0);<br \/>\nclosesocket(Remote);<br \/>\nWSACleanup();<br \/>\nSendMessage(hwnd,WM_CLOSE,0,0);<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase ID_SEND:<br \/>\nif ( strcmp(sendToIp,ipAdd)&#061;&#061;0 )<br \/>\n{<br \/>\nMessageBoxA(hwnd,&#034;\u4e0d\u5141\u8bb8\u548c\u81ea\u5df1\u79c1\u804a!&#034;,&#034;\u63d0\u793a&#034;,MB_OK);<br \/>\nreturn 0;<br \/>\n}<br \/>\nif (strcmp(sendToIp,&#034;\u6240\u6709\u4eba&#034;)&#061;&#061;0)<br \/>\n{<br \/>\n\/\/\/CreateThread(NULL,NULL,ThreadSend,NULL,NULL,NULL);\/\/\u521b\u5efa\u7ebf\u7a0b\u8d1f\u8d23\u53d1\u9001\u6570\u636e<br \/>\nchar szText[99999];<br \/>\nchar cBuff[2000];<br \/>\nTCHAR Time[15];<br \/>\nGetWindowTextA(hSendText, cBuff, 1950);\/\/\u83b7\u53d6\u9700\u8981\u53d1\u9001\u7684\u5185\u5bb9<br \/>\nsend(Remote, cBuff, strlen(cBuff) &#043; 1, 0);\/\/\u5f00\u59cb\u53d1\u9001<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\/\/CreateThread(NULL,NULL,ThreadSend,(LPVOID)sendToIp,NULL,NULL);\/\/\u521b\u5efa\u7ebf\u7a0b\u8d1f\u8d23\u53d1\u9001\u6570\u636e<br \/>\nchar szText[99999];<br \/>\nchar cBuff[2000];<br \/>\nTCHAR Time[15];<br \/>\nGetWindowTextA(hSendText, cBuff, 1950);\/\/\u83b7\u53d6\u9700\u8981\u53d1\u9001\u7684\u5185\u5bb9<br \/>\nstd::string str &#061; cBuff;<br \/>\nstr &#043;&#061; &#034;wmsl&#034;;<br \/>\nstr &#043;&#061; sendToIp;<br \/>\nstr &#043;&#061; &#034;#&#034;;<br \/>\nstr &#043;&#061; cBuff;<br \/>\nsend(Remote, str.c_str(), str.size() &#043; 1, 0);\/\/\u5f00\u59cb\u53d1\u9001<\/p>\n<p>}<br \/>\nreturn 0;<br \/>\ndefault:<br \/>\nreturn 0;<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase WM_DESTROY:<br \/>\nPostQuitMessage(0) ;<br \/>\nreturn 0 ;<br \/>\n}<br \/>\nreturn DefWindowProc(hwnd, message, wParam, lParam);<br \/>\n}<\/p>\n<p>\/\/\u6b64\u4e3a\u5efa\u7acb\u8fde\u63a5\u7684\u7ebf\u7a0b<br \/>\nDWORD WINAPI ThreadConnect(LPVOID p)<br \/>\n{<br \/>\nRemoteAdd.sin_family &#061; AF_INET;<br \/>\nRemoteAdd.sin_port &#061; htons(12057);<br \/>\nRemote &#061; socket(AF_INET, SOCK_STREAM, 0);<\/p>\n<p>if ( connect(Remote,(sockaddr*)&amp;RemoteAdd,sizeof(RemoteAdd))&#061;&#061;-1 )<br \/>\n{<br \/>\nMessageBoxA(hwnd,&#034;\u8fde\u63a5\u670d\u52a1\u5668\u5931\u8d25,\u8bf7\u68c0\u67e5IP\u5730\u5740\u662f\u5426\u6b63\u786e&#034;,&#034;\u8fde\u63a5\u5931\u8d25&#034;,MB_OK);<br \/>\nEnableWindow(hConnectBtn,1);<br \/>\nreturn 0;<br \/>\n}<br \/>\nEnableWindow(hSendBtn,1);<br \/>\nEnableWindow(hConnectBtn,0);<br \/>\nEnableWindow(hSendText,1);<br \/>\nEnableWindow(hIpInput,0);<br \/>\nEnableWindow(hCloseLinkBtn,1);<br \/>\nSetWindowTextA(hState,&#034;\u8fde\u63a5\u72b6\u6001:\u5df2\u8fde\u63a5&#034;);<br \/>\nisClose&#061;false;<br \/>\nThdRecv&#061;CreateThread(NULL,NULL,ThreadRecv,NULL,NULL,NULL); \/\/\u8fde\u63a5\u6210\u529f\u5219\u521b\u5efa\u63a5\u6536\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u6b64\u4e3a\u63a5\u6536\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\nDWORD WINAPI ThreadRecv(LPVOID p)<br \/>\n{<br \/>\nchar szText[99999];<br \/>\nwhile(!isClose)<br \/>\n{<br \/>\nchar Time[30];<br \/>\nchar cBuff[255];<br \/>\nint n&#061;0;<br \/>\nn&#061;recv(Remote,cBuff,256,0);<br \/>\ncBuff[n]&#061;&#039;\\\\0&#039;;<br \/>\n\/\/\u5224\u65ad\u6d88\u606f\u662f\u5426\u4e3a\u547d\u4ee4\u6d88\u606f<br \/>\nif ( cBuff[0]&#061;&#061;&#039;y&#039; &amp;&amp; cBuff[1]&#061;&#061;&#039;#&#039; )\/\/\u5173\u95ed<br \/>\n{<br \/>\nbreak;<br \/>\n}<\/p>\n<p>\/\/\u83b7\u53d6\u5217\u8868<br \/>\nif ( cBuff[0]&#061;&#061;&#039;k&#039; &amp;&amp; cBuff[1]&#061;&#061;&#039;h&#039; &amp;&amp; cBuff[2]&#061;&#061;&#039;i&#039; &amp;&amp; cBuff[3]&#061;&#061;&#039;p&#039;  )<br \/>\n{<br \/>\nSendMessageA(hClientList,LB_RESETCONTENT ,0,0);\/\/\u6e05\u7a7a\u5ba2\u6237\u7aef\u5217\u8868,\u7136\u540e\u91cd\u65b0\u6dfb\u52a0<br \/>\nSendMessageA(hClientList,LB_ADDSTRING,0,(LPARAM)&#034;\u6240\u6709\u4eba&#034;);<br \/>\nchar a[21];<br \/>\nstrcpy(a,&#034;&#034;);<br \/>\n\/\/\u4f9d\u6b21\u53d6\u51fa\u6bcf\u4e2a\u5ba2\u6237\u7aefIP<br \/>\nfor ( int i&#061;4; cBuff[i]!&#061;&#039;\\\\0&#039;; i&#043;&#043;)<br \/>\n{<br \/>\nif ( cBuff[i]!&#061;&#039;#&#039;)\/\/\u9047\u5230\u5b57\u7b26&#034;#&#034;\u8bf4\u660e\u83b7\u53d6\u5230\u4e86\u4e00\u4e2a\u5b8c\u6574\u7684IP\u5730\u5740<br \/>\n{<br \/>\nchar temp[2];<br \/>\nsprintf(temp,&#034;%c&#034;,cBuff[i]);<br \/>\nstrcat(a,temp);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nSendMessageA(hClientList,LB_ADDSTRING,0,(LPARAM)a);<br \/>\nstrcpy(a,&#034;&#034;);<br \/>\n}<br \/>\n}<br \/>\ncontinue;<br \/>\n}<br \/>\nGetWindowTextA(hTextList,szText,99999);\/\/\u83b7\u53d6\u5386\u53f2\u8bb0\u5f55\u6587\u672c\u6846\u4e2d\u7684\u5185\u5bb9<br \/>\nGetLocalTime(&amp;sysTime);<br \/>\n\/\/\u683c\u5f0f\u5316\u8f93\u51fa\u65f6\u95f4<br \/>\nsprintf(Time,&#034;%d:%d:%d&#034;,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);<br \/>\nstrcat(szText,Time);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n&#034;); \/\/\u6362\u884c<br \/>\nstrcat(szText,cBuff);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n\\\\r\\\\n&#034;); \/\/\u6362\u884c<br \/>\nSetWindowTextA(hTextList,szText);<br \/>\n}<br \/>\nEnableWindow(hSendBtn,0);<br \/>\nEnableWindow(hConnectBtn,1);<br \/>\nEnableWindow(hSendText,0);<br \/>\nEnableWindow(hIpInput,1);<br \/>\nEnableWindow(hCloseLinkBtn,0);<br \/>\nSetWindowTextA(hState,&#034;\u8fde\u63a5\u72b6\u6001:\u672a\u8fde\u63a5&#034;);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\u6b64\u4e3a\u53d1\u9001\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\n\/\/DWORD WINAPI ThreadSend(LPVOID p)<br \/>\n\/\/{<br \/>\n\/\/<br \/>\n\/\/return 0;<br \/>\n\/\/}<br \/>\n\/\/\u670d\u52a1\u5668\u7aef\u4ee3\u7801<\/p>\n<p>#include &lt;Windows.h&gt;<br \/>\n#include &lt;TOM.h&gt;<br \/>\n#include &lt;string.h&gt;<br \/>\n#include &lt;tchar.h&gt;<br \/>\n#include &lt;stdio.h&gt;<br \/>\n#include &lt;map&gt;<br \/>\n#define ID_STATIC 1<br \/>\n#define ID_TEXT 2<br \/>\n#define ID_TEXTSEND 3<br \/>\n#define ID_CLOSE 4<br \/>\n#define ID_SEND 5<br \/>\n#define ID_LISTEN 6<br \/>\n#define ID_CLIENTLIST 7<br \/>\n#define ID_TIMER1 10<br \/>\nusing namespace std;<br \/>\n#pragma comment(lib,&#034;wsock32.lib&#034;)<\/p>\n<p>\/\/\u5168\u5c40\u53d8\u91cf<br \/>\nTCHAR szClassName[] &#061; TEXT(&#034;MyWindowClass&#034;);  \/\/\u7a97\u53e3\u7c7b\u540d<br \/>\nTCHAR szWindowName[] &#061; TEXT(&#034;\u7f51\u7edc\u804a\u5929\u5ba4&#8212;\u670d\u52a1\u5668&#034;); \/\/\u7a97\u53e3\u6807\u9898\u540d<\/p>\n<p>HWND hdlg;<br \/>\nHWND hwnd;<br \/>\nWSADATA wsaData;<br \/>\nSOCKET srv;\/\/\u672c\u5730\u5957\u63a5\u5b57<br \/>\nsockaddr_in sockin;\/\/\u672c\u5730\u5730\u5740\u4fe1\u606f<br \/>\nHANDLE ThdAccept,ThdSend; \/\/\u7ebf\u7a0b\u53e5\u67c4<br \/>\nSYSTEMTIME sysTime;\/\/\u65f6\u95f4\u4fe1\u606f<br \/>\nHWND hTip,hTextList,hSendText,hCloseBtn,hSendBtn,hListenBtn,hClientList;\/\/\u5404\u4e2a\u63a7\u4ef6\u53e5\u67c4<br \/>\nmap&lt;SOCKET,sockaddr_in&gt; allClients;\/\/\u5ba2\u6237\u7aef\u5957\u63a5\u5b57\u548c\u5730\u5740\u4fe1\u606f\u7684\u4e00\u4e00\u6620\u5c04<br \/>\nchar szClientList[25010];\/\/\u4fdd\u5b58\u5ba2\u6237\u7aefIP\u4e32,\u7528\u4e8e\u5ba2\u6237\u7aef\u83b7\u53d6<\/p>\n<p>\/\/\u51fd\u6570\u58f0\u660e<br \/>\nATOMMyRegisterClass(HINSTANCE hInstance);      \/\/ \u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u51fd\u6570<br \/>\nBOOLInitInstance(HINSTANCE, int);              \/\/ \u521d\u59cb\u5316\u51fd\u6570&#xff08;\u521b\u5efa\u5e76\u663e\u793a\u7a97\u53e3&#xff09;<br \/>\nLRESULT CALLBACKWndProc(HWND, UINT, WPARAM, LPARAM);       \/\/ \u7a97\u53e3\u51fd\u6570<br \/>\nBOOL CALLBACK DlgProc (HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam);<br \/>\nDWORD WINAPI ThreadAccept(LPVOID p);<br \/>\nDWORD WINAPI ThreadRecv(LPVOID p);<br \/>\nDWORD WINAPI ThreadSend(LPVOID p);<br \/>\nDWORD WINAPI ThreadUpdate(LPVOID p);<\/p>\n<p>\/\/****\u5165\u53e3\u51fd\u6570*************************************<br \/>\nint WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstanc,LPSTR lpCmdLine,int nCmdShow)<br \/>\n{<br \/>\nMSG msg;<\/p>\n<p>\/\/\u8fd0\u884c\u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u7684\u51fd\u6570<br \/>\nMyRegisterClass(hInstance);<\/p>\n<p>\/\/\u6267\u884c\u5e94\u7528\u7a0b\u5e8f\u521d\u59cb\u5316<br \/>\nif (!InitInstance (hInstance, nCmdShow))<br \/>\n{<br \/>\nreturn FALSE;<br \/>\n}<\/p>\n<p>\/\/\u4e3b\u6d88\u606f\u5faa\u73af<br \/>\nwhile(GetMessage(&amp;msg, NULL, 0, 0))   \/\/\u4ece\u6d88\u606f\u961f\u5217\u4e2d\u53d6\u51fa\u6d88\u606f<br \/>\n{<br \/>\nTranslateMessage(&amp;msg);   \/\/ \u5c06\u6309\u952e\u6d88\u606f\u8f6c\u6362\u4e3a\u5b57\u7b26\u6d88\u606f<br \/>\nDispatchMessage(&amp;msg);    \/\/ \u5c06\u6d88\u606f\u53d1\u9001\u5230\u76f8\u5e94\u7684\u7a97\u53e3\u51fd\u6570<br \/>\n}<\/p>\n<p>return (int)msg.wParam;   \/\/ \u5f53GetMessage\u8fd4\u56de0\u65f6\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u5c06MSG\u7684wParam\u53c2\u6570\u8fd4\u56de\u64cd\u4f5c\u7cfb\u7edf<br \/>\n}<\/p>\n<p>\/\/****\u5b9a\u4e49\u53ca\u6ce8\u518c\u7a97\u53e3\u7c7b\u51fd\u6570*************************<br \/>\nATOM MyRegisterClass(HINSTANCE hInstance)<br \/>\n{<br \/>\nWNDCLASS wc;<\/p>\n<p>\/\/ \u7528\u63cf\u8ff0\u4e3b\u7a97\u53e3\u7684\u53c2\u6570\u586b\u5145WNDCLASS\u7ed3\u6784<br \/>\nwc.style &#061; CS_HREDRAW|CS_VREDRAW;   \/\/ \u6307\u5b9a\u5982\u679c\u7a97\u53e3\u5927\u5c0f\u6539\u53d8\u5c31\u91cd\u7ed8<br \/>\nwc.lpfnWndProc &#061; WndProc;        \/\/ \u7a97\u53e3\u51fd\u6570\u6307\u9488<br \/>\nwc.cbClsExtra &#061; 0;            \/\/ \u6ca1\u6709\u989d\u5916\u7684\u7c7b\u5185\u5b58<br \/>\nwc.cbWndExtra &#061; 0;            \/\/ \u6ca1\u6709\u989d\u5916\u7684\u7a97\u53e3\u5185\u5b58<br \/>\nwc.hInstance &#061; hInstance;    \/\/ \u5b9e\u4f8b\u53e5\u67c4<br \/>\nwc.hIcon &#061; LoadIcon(NULL, IDI_APPLICATION);                \/\/ \u4f7f\u7528\u9884\u5b9a\u4e49\u56fe\u6807<br \/>\nwc.hCursor &#061; LoadCursor(NULL, IDC_ARROW);            \/\/ \u4f7f\u7528\u9884\u5b9a\u4e49\u5149\u6807<br \/>\nwc.hbrBackground &#061; (HBRUSH)GetStockObject(WHITE_BRUSH);    \/\/ \u4f7f\u7528\u767d\u8272\u80cc\u666f\u753b\u5237<br \/>\nwc.lpszMenuName &#061; NULL;                                \/\/ \u4e0d\u6307\u5b9a\u83dc\u5355<br \/>\nwc.lpszClassName &#061; szClassName ;                        \/\/ \u7a97\u53e3\u7c7b\u7684\u540d\u79f0<\/p>\n<p>return RegisterClass(&amp;wc);          \/\/\u6ce8\u518c\u7a97\u53e3\u7c7b&#xff0c;\u5982\u679c\u6210\u529f\u5219\u8fd4\u56de\u4e00\u4e2aatom\u503c&#xff0c;\u5931\u8d25\u5219\u8fd4\u56de0<br \/>\n}<\/p>\n<p>\/\/****\u521d\u59cb\u5316\u51fd\u6570************************************<br \/>\nBOOL InitInstance(HINSTANCE hInstance, int nCmdShow)<br \/>\n{<\/p>\n<p>hwnd &#061; CreateWindow(szClassName, szWindowName, WS_OVERLAPPEDWINDOW,<br \/>\n200,50,670, 550, NULL, NULL, hInstance, NULL);<\/p>\n<p>if (!hwnd)<br \/>\n{<br \/>\nreturn FALSE;<br \/>\n}<\/p>\n<p>ShowWindow(hwnd,nCmdShow);<br \/>\nUpdateWindow(hwnd);<br \/>\n\/\/\u521b\u5efa\u6240\u9700\u63a7\u4ef6<br \/>\nhTip&#061;CreateWindowA(&#034;static&#034;,&#034;\u8fde\u63a5\u72b6\u6001:\u7b49\u5f85\u76d1\u542c&#034;,WS_VISIBLE|WS_CHILD,<br \/>\n10,10,150,20,hwnd,(HMENU)1,hInstance,NULL);<br \/>\nhTextList&#061;CreateWindowA(&#034;edit&#034;,&#034;&#034;,WS_CHILD|WS_VISIBLE|WS_BORDER|<br \/>\nES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL,<br \/>\n10,30,450,300,hwnd,(HMENU)2,hInstance,NULL);<\/p>\n<p>hSendText&#061;CreateWindowA(&#034;edit&#034;,&#034;&#034;,WS_CHILD|WS_VISIBLE|WS_BORDER|<br \/>\nES_MULTILINE|ES_AUTOVSCROLL|WS_VSCROLL,<br \/>\n10,350,450,100,hwnd,(HMENU)3,hInstance,NULL);<br \/>\nhCloseBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u5173\u95ed&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,<br \/>\n300,455,50,25,hwnd,(HMENU)4,hInstance,NULL);<br \/>\nhSendBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u53d1\u9001&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_DISABLED,<br \/>\n390,455,50,25,hwnd,(HMENU)5,hInstance,NULL);<br \/>\nhListenBtn&#061;CreateWindowA(&#034;button&#034;,&#034;\u76d1\u542c&#034;,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,<br \/>\n400,5,50,25,hwnd,(HMENU)6,hInstance,NULL);<\/p>\n<p>CreateWindowA(&#034;static&#034;,&#034;\u5ba2\u6237\u7aef\u5217\u8868&#034;,WS_VISIBLE|WS_CHILD ,<br \/>\n490,8,100,20,hwnd,NULL,hInstance,NULL);<\/p>\n<p>hClientList&#061;CreateWindowA(&#034;listbox&#034;,&#034;\u5217\u8868&#034;,WS_CHILD|WS_VISIBLE|LBS_HASSTRINGS|LBS_NOTIFY ,<br \/>\n480,35,150,305,hwnd,(HMENU)7,hInstance,NULL);<\/p>\n<p>return TRUE;<br \/>\n}<\/p>\n<p>\/\/****\u7a97\u53e3\u51fd\u6570**************************************<br \/>\nLRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<br \/>\n{<br \/>\nHDC hdc;<\/p>\n<p>PAINTSTRUCT ps;<br \/>\nstatic HBITMAP hBitmap;<br \/>\nstatic BITMAP bg;<br \/>\nstatic HDC hdcMem;<br \/>\nswitch (message)<br \/>\n{<br \/>\ncase WM_PAINT:<br \/>\nhdc &#061; BeginPaint (hwnd, &amp;ps);<br \/>\nSelectObject(hdcMem,hBitmap);<br \/>\nBitBlt(hdc,0,0,bg.bmWidth,bg.bmHeight,hdcMem,0,0,SRCCOPY);<br \/>\nEndPaint(hwnd, &amp;ps);<br \/>\nreturn 0;<br \/>\ncase WM_CREATE:<br \/>\n{<br \/>\n\/\/\u521d\u59cb\u5316<br \/>\nWSAStartup(MAKEWORD(2,0),&amp;wsaData);<br \/>\nsockin.sin_family&#061;AF_INET;<br \/>\nsockin.sin_port&#061;htons(12057);<br \/>\nsockin.sin_addr.S_un.S_addr&#061;INADDR_ANY;<br \/>\nsrv&#061;socket(AF_INET,SOCK_STREAM,0);<\/p>\n<p>hBitmap&#061;(HBITMAP)LoadImage(NULL,TEXT(&#034;pic\\\\\\\\bg.BMP&#034;),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br \/>\nGetObject(hBitmap,sizeof(BITMAP),&amp;bg);<br \/>\nhdc&#061;GetDC(hwnd);<br \/>\nhdcMem&#061;CreateCompatibleDC(hdc);<br \/>\nReleaseDC(hwnd,hdc);<br \/>\nstrcat(szClientList,&#034;khip&#034;);\/\/\u8bbe\u7f6e\u6d88\u606f\u5934<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase WM_COMMAND:<br \/>\nswitch(LOWORD(wParam))<br \/>\n{<br \/>\ncase ID_LISTEN:<br \/>\n{<br \/>\nif (bind(srv,(LPSOCKADDR)&amp;sockin,sizeof(sockin))&#061;&#061;SOCKET_ERROR )<br \/>\n{<br \/>\nMessageBox(hwnd,TEXT(&#034;\u63a7\u5236\u7aef\u53e3\u88ab\u5360\u7528,\u76d1\u542c\u5931\u8d25!&#034;),TEXT(&#034;\u5931\u8d25&#034;),MB_OK);<br \/>\nWSACleanup();<br \/>\nreturn 0;<br \/>\n}<br \/>\nif (listen(srv,2)&#061;&#061;SOCKET_ERROR)<br \/>\n{<br \/>\nMessageBox(hwnd,TEXT(&#034;\u76d1\u542c\u5931\u8d25&#xff01;&#034;),TEXT(&#034;\u5931\u8d25&#034;),MB_OK);<br \/>\nWSACleanup();<br \/>\nreturn 0;<br \/>\n}<br \/>\nEnableWindow(hListenBtn,0);\/\/\u8bbe\u7f6e\u6309\u94ae\u65e0\u6548<br \/>\nSetWindowTextA(hTip,&#034;\u8fde\u63a5\u72b6\u6001&#xff1a;\u7b49\u5f85\u8fde\u63a5&#034;);\/\/\u8bbe\u7f6e\u9759\u6001\u6587\u672c\u5185\u5bb9<br \/>\nThdAccept&#061;CreateThread(NULL,NULL,ThreadAccept,NULL,NULL,NULL);\/\/\u521b\u5efa\u63a5\u53d7\u8fde\u63a5\u7684\u7ebf\u7a0b<br \/>\nreturn 0;<br \/>\n}<br \/>\ncase ID_CLOSE:<br \/>\nSendMessage(hwnd,WM_CLOSE,0,0);<br \/>\nreturn 0;<br \/>\ncase ID_SEND:<br \/>\nCreateThread(NULL,NULL,ThreadSend,NULL,NULL,NULL);\/\/\u53d1\u9001\u6570\u636e<br \/>\nreturn 0;<br \/>\n}<br \/>\nreturn 0;<br \/>\ncase WM_DESTROY:<br \/>\nKillTimer(hwnd,ID_TIMER1);<br \/>\nPostQuitMessage(0);<br \/>\nreturn 0 ;<br \/>\n}<br \/>\nreturn DefWindowProc(hwnd, message, wParam, lParam);<br \/>\n}<\/p>\n<p>\/\/\u6b64\u4e3a\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u7ebf\u7a0b<br \/>\nDWORD WINAPI ThreadAccept(LPVOID p)<br \/>\n{<br \/>\nwhile(true)<br \/>\n{<br \/>\nSOCKET client;<br \/>\nsockaddr_in clientAdd;<br \/>\nint addrlen&#061;sizeof(clientAdd);<br \/>\nclient&#061;accept(srv,(SOCKADDR*)&amp;clientAdd,&amp;addrlen);\/\/\u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5<br \/>\nif (client&#061;&#061;INVALID_SOCKET)<br \/>\n{<br \/>\nWSACleanup();<br \/>\nEnableWindow(hListenBtn,1);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nEnableWindow(hSendBtn,1);<br \/>\nCreateThread(NULL,NULL,ThreadRecv,(LPVOID)client,NULL,NULL); \/\/\u8fde\u63a5\u6210\u529f\u5219\u521b\u5efa\u63a5\u6536\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\nallClients[client]&#061;clientAdd;<br \/>\nchar a[30];<br \/>\nsprintf(a,&#034;\u5f53\u524d\u8fde\u63a5\u5ba2\u6237\u7aef:%d \u4e2a&#034;,allClients.size());<br \/>\nSetWindowTextA(hTip,a);\/\/\u63d0\u793a\u8fde\u63a5\u4e2a\u6570<br \/>\nsprintf(a,&#034;%s&#034;,inet_ntoa(clientAdd.sin_addr));<br \/>\nSendMessageA(hClientList,LB_ADDSTRING,0,(LPARAM)a);\/\/\u8bbe\u7f6e\u5ba2\u6237\u7aef\u5217\u8868<br \/>\nstrcat(szClientList,a);<br \/>\nstrcat(szClientList,&#034;#&#034;);<br \/>\nCreateThread(NULL,NULL,ThreadUpdate,NULL,NULL,NULL);<br \/>\n}<\/p>\n<p>}<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u6b64\u4e3a\u63a5\u6536\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\nDWORD WINAPI ThreadRecv(LPVOID p)<br \/>\n{<br \/>\nchar szText[99999];<\/p>\n<p>while(true)<br \/>\n{<br \/>\nchar Time[15];<br \/>\nchar cBuff[2000];<br \/>\nrecv((SOCKET)p,cBuff,2000,0);<br \/>\n\/\/\u5ba2\u6237\u7aef\u8bf7\u6c42\u65ad\u5f00<br \/>\nif (cBuff[0]&#061;&#061;&#039;q&#039; &amp;&amp; cBuff[1]&#061;&#061;&#039;#&#039;)<br \/>\n{<br \/>\nbreak;<br \/>\n}<br \/>\n\/\/\u5ba2\u6237\u7aef\u8bf7\u6c42\u79c1\u804a<br \/>\nif (cBuff[0]&#061;&#061;&#039;w&#039; &amp;&amp; cBuff[1]&#061;&#061;&#039;m&#039; &amp;&amp; cBuff[2]&#061;&#061;&#039;s&#039; &amp;&amp; cBuff[3]&#061;&#061;&#039;l&#039;)<br \/>\n{<br \/>\nchar sendToIp[20];\/\/\u76ee\u6807&#xff29;&#xff30;<br \/>\nchar a[50];<br \/>\nstrcpy(sendToIp,&#034;&#034;);<br \/>\n int i;<br \/>\nfor (i&#061;4; cBuff[i]!&#061;&#039;#&#039;; i&#043;&#043;)<br \/>\n{<br \/>\nchar temp[2];<br \/>\nstrcpy(temp,&#034;&#034;);<br \/>\nsprintf(temp,&#034;%c&#034;,cBuff[i]);\/\/\u53d6\u51fa\u76ee\u6807&#xff29;&#xff30;&#xff0c;<br \/>\nstrcat(sendToIp,temp);<br \/>\n}<br \/>\n\/\/\u8bbe\u7f6e\u63a5\u6536\u65b9\u6240\u9700\u6570\u636e<br \/>\nchar *cTemp&#061;new char[strlen(cBuff)];<br \/>\nstrcpy(cTemp,sendToIp);<br \/>\nstrcat(cTemp,&#034;#&#034;);<br \/>\nsprintf(a,&#034;%s\u6084\u6084\u5bf9\u6211\u8bf4:\\\\r\\\\n&#034;,inet_ntoa(allClients[(SOCKET)p].sin_addr));<br \/>\nstrcat(cTemp,a);<br \/>\nstrcat(cTemp,cBuff&#043;i&#043;1);<\/p>\n<p>CreateThread(NULL,NULL,ThreadSend,(LPVOID)cTemp,NULL,NULL);\/\/\u53d1\u9001\u6570\u636e<br \/>\n\/\/\u663e\u793a\u5ba2\u6237\u7aef\u79c1\u804a\u4fe1\u606f<br \/>\nGetWindowTextA(hTextList,szText,99999);\/\/\u83b7\u53d6\u5386\u53f2\u8bb0\u5f55\u6587\u672c\u6846\u4e2d\u7684\u5185\u5bb9<br \/>\nGetLocalTime(&amp;sysTime);<br \/>\nsprintf(Time,&#034;%d:%d:%d&#034;,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);<br \/>\nstrcat(szText,Time);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n&#034;);<br \/>\nsprintf(a,&#034;%s\u6084\u6084\u5bf9%s\u8bf4:\\\\r\\\\n&#034;,inet_ntoa(allClients[(SOCKET)p].sin_addr),sendToIp);<br \/>\nstrcat(szText,a);<br \/>\nstrcat(szText,cBuff&#043;i&#043;1);<\/p>\n<p>strcat(szText,&#034;\\\\r\\\\n\\\\r\\\\n&#034;); \/\/\u6362\u884c<br \/>\nSetWindowTextA(hTextList,szText);<\/p>\n<p>\/\/\u56de\u5e94\u79c1\u804a\u65b9\u79c1\u804a\u6210\u529f<br \/>\nchar *Temp&#061;new char[strlen(cBuff)];<br \/>\nstrcpy(Temp,&#034;&#034;);<br \/>\nsprintf(a,&#034;\u6211\u5bf9%s\u6084\u6084\u8bf4:\\\\r\\\\n&#034;,sendToIp);<br \/>\nstrcat(Temp,a);<br \/>\nstrcat(Temp,cBuff&#043;i&#043;1);<br \/>\nsend((SOCKET)p,Temp,strlen(Temp)&#043;4,0);<\/p>\n<p>continue;<br \/>\n}<br \/>\nGetWindowTextA(hTextList,szText,99999);\/\/\u83b7\u53d6\u5386\u53f2\u8bb0\u5f55\u6587\u672c\u6846\u4e2d\u7684\u5185\u5bb9<br \/>\nGetLocalTime(&amp;sysTime);<br \/>\n\/\/\u683c\u5f0f\u5316\u8f93\u51fa\u65f6\u95f4<br \/>\nsprintf(Time,&#034;%d:%d:%d&#034;,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);<br \/>\nstrcat(szText,Time);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n&#034;);<br \/>\nchar *a&#061;new char[strlen(cBuff)&#043;20];<br \/>\nsprintf(a,&#034;%s\u5bf9\u5927\u5bb6\u8bf4:&#034;,inet_ntoa(allClients[(SOCKET)p].sin_addr));<br \/>\nstrcat(a,cBuff);<br \/>\nfor (map&lt;SOCKET,sockaddr_in&gt; ::iterator itr&#061;allClients.begin(); itr!&#061;allClients.end(); itr&#043;&#043;)<br \/>\n{<br \/>\nsend(itr-&gt;first,a,strlen(a)&#043;1,0);<br \/>\n}<br \/>\nstrcat(szText,a);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n\\\\r\\\\n&#034;); \/\/\u6362\u884c<br \/>\nSetWindowTextA(hTextList,szText); \/\/\u8bbe\u7f6e\u5386\u53f2\u8bb0\u5f55<br \/>\n}<br \/>\n\/\/\u5f53\u6b64\u5ba2\u6237\u7aef\u65ad\u5f00\u8fde\u63a5\u540e\u6267\u884c\u4ee5\u4e0b\u64cd\u4f5c<br \/>\nallClients.erase(allClients.find((SOCKET)p));\/\/\u79fb\u9664\u65ad\u5f00\u7684\u5ba2\u6237\u7aef\u4fe1\u606f<br \/>\nchar a[30];<br \/>\nsprintf(a,&#034;\u5f53\u524d\u8fde\u63a5\u5ba2\u6237\u7aef:%d \u4e2a&#034;,allClients.size());<br \/>\nSetWindowTextA(hTip,a);<\/p>\n<p>\/\/\u66f4\u65b0\u5ba2\u6237\u7aef\u5217\u8868<br \/>\nSendMessage(hClientList,LB_RESETCONTENT ,0,0);\/\/\u6e05\u7a7a\u5217\u8868;<br \/>\nstrcpy(szClientList,&#034;khip&#034;);\/\/\u8bbe\u7f6e\u6d88\u606f\u5934<br \/>\nfor( map&lt;SOCKET,sockaddr_in&gt; ::iterator itr&#061;allClients.begin(); itr!&#061;allClients.end(); itr&#043;&#043;)<br \/>\n{<br \/>\nchar a[60];\/\/\u904d\u5386\u5f53\u524d\u8fde\u63a5\u7684\u5ba2\u6237\u7aef,\u8bbe\u7f6e\u5ba2\u6237\u7aef\u5217\u8868<br \/>\nsprintf(a,&#034;%s&#034;,inet_ntoa(itr-&gt;second.sin_addr));<br \/>\nSendMessageA(hClientList,LB_ADDSTRING,0,(LPARAM)a);<br \/>\n\/\/printf(&#034;%s\\\\n&#034;,a);<br \/>\n \/\/\u5c06\u5404\u4e2a\u5ba2\u6237\u7aefIP\u6dfb\u52a0\u5230IP\u5b57\u7b26\u4e32\u4e2d<br \/>\nstrcat(szClientList,a);<br \/>\nstrcat(szClientList,&#034;#&#034;);<br \/>\n}<br \/>\nCreateThread(NULL,NULL,ThreadUpdate,NULL,NULL,NULL);<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u6b64\u4e3a\u53d1\u9001\u6570\u636e\u7684\u7ebf\u7a0b<br \/>\nDWORD WINAPI ThreadSend(LPVOID p)<br \/>\n{<br \/>\nchar szText[99999] ;<br \/>\nchar cBuff[2100];<br \/>\nchar Time[15];<br \/>\nif ( p )<br \/>\n{<br \/>\nint i,j;<br \/>\nstrcpy(cBuff,&#034;&#034;);<br \/>\nstrcpy(cBuff,(char*)p);<\/p>\n<p>char a[30];<br \/>\nstrcpy(a,&#034;&#034;);<br \/>\nfor (j&#061;0; cBuff[j]!&#061;&#039;#&#039;; j&#043;&#043;)<br \/>\n{<br \/>\nchar temp[2];<br \/>\nsprintf(temp,&#034;%c&#034;,cBuff[j]);<br \/>\nstrcat(a,temp);<br \/>\n}<br \/>\ni&#061;SendMessageA(hClientList,LB_FINDSTRING,-1,(LPARAM)a);\/\/ \u4ece\u5217\u8868\u4e2d\u67e5\u627e\u76ee\u6807&#xff29;&#xff30;<br \/>\nmap&lt;SOCKET,sockaddr_in&gt; ::iterator itr&#061;allClients.begin();\/\/\u3000\u6839\u636e\u76ee\u6807&#xff29;&#xff30;\u7684\u4f4d\u7f6e\u4ece\u6620\u5c04\u4e2d\u627e\u5230\u5176SOCKET<br \/>\nfor (int k&#061;0; k!&#061;i; k&#043;&#043;)<br \/>\n{<br \/>\nitr&#043;&#043;;<br \/>\n}<br \/>\nsend(itr-&gt;first,cBuff&#043;j&#043;1,strlen(cBuff),0);\/\/\u5728\u627e\u5230\u7684&#xff33;&#xff2f;&#xff23;&#xff2b;&#xff25;&#xff34;\u4e0a\u53d1\u9001\u6d88\u606f<br \/>\nreturn 0;<br \/>\n}<br \/>\nGetWindowTextA(hSendText,cBuff,2000);\/\/\u83b7\u53d6\u9700\u8981\u53d1\u9001\u7684\u5185\u5bb9<br \/>\nSetWindowTextA(hSendText,&#034;&#034;);<br \/>\nGetWindowTextA(hTextList,szText,99999);\/\/\u83b7\u53d6\u5386\u53f2\u8bb0\u5f55\u6587\u672c\u6846\u4e2d\u7684\u5185\u5bb9<br \/>\nGetLocalTime(&amp;sysTime);<br \/>\n\/\/\u683c\u5f0f\u5316\u8f93\u51fa\u65f6\u95f4<br \/>\nsprintf(Time,&#034;%d:%d:%d&#034;,sysTime.wHour,sysTime.wMinute,sysTime.wSecond);<br \/>\nstrcat(szText,Time);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n&#034;);<br \/>\nchar *a&#061;new char[2020];<br \/>\nstrcpy(a,&#034;&#034;);<br \/>\nstrcat(a,&#034;\u670d\u52a1\u5668\u5bf9\u5927\u5bb6\u8bf4:&#034;);<br \/>\nstrcat(a,cBuff);<br \/>\nfor (map&lt;SOCKET,sockaddr_in&gt; ::iterator itr&#061;allClients.begin(); itr!&#061;allClients.end(); itr&#043;&#043;)<br \/>\n{<br \/>\nsend(itr-&gt;first,a,strlen(a)&#043;1,0);<br \/>\n}<br \/>\nstrcat(szText,a);<br \/>\nstrcat(szText,&#034;\\\\r\\\\n&#034;); \/\/\u6362\u884c<br \/>\nSetWindowTextA(hTextList,szText); \/\/\u8bbe\u7f6e\u5386\u53f2\u8bb0\u5f55<br \/>\ndelete []a;<br \/>\nreturn 0;<br \/>\n}<\/p>\n<p>\/\/\u66f4\u65b0\u4fe1\u606f<br \/>\nDWORD WINAPI ThreadUpdate(LPVOID p)<br \/>\n{<br \/>\n\/\/\u5c06\u4fe1\u606f\u66f4\u65b0\u81f3\u6bcf\u4e2a\u5ba2\u6237\u7aef<br \/>\nfor( map&lt;SOCKET,sockaddr_in&gt; ::iterator itr&#061;allClients.begin(); itr!&#061;allClients.end(); itr&#043;&#043;)<br \/>\n{<br \/>\nsend(itr-&gt;first,szClientList,strlen(szClientList)&#043;1,0);<br \/>\n}<br \/>\nreturn 0;<br \/>\n} <\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130823-68024ec762572.png\" \/> \u63a5\u4e0b\u6765\u6211\u8981\u8bb2\u89e3\u4e00\u4e0b\u5927\u6982\u539f\u7406 windows\u662f\u901a\u8fc7\u6d88\u606f\u6765\u4f20\u9012\u4fe1\u53f7&#xff0c;\u4f60\u53ef\u4ee5\u7406\u89e3\u4e3a\u6709\u4eba\u7ed9\u4f60\u6572\u95e8\u6572\u95e8\u7684\u58f0\u97f3\u5c31\u662f\u6d88\u606f&#xff08;\u6d88\u606f\u4e8b\u4ef6&#xff09;&#xff0c;\u7136\u540e\u4f60\u542c\u5230\u540e\u5c31\u6709\u76f8\u5e94\u7684\u64cd\u4f5c&#xff08;\u5bf9\u5e94\u7684\u6d88\u606f\u5904\u7406\u51fd\u6570&#xff09; \u4f60\u5904\u7406\u5b8c\u4e8b\u60c5\u540e\u662f\u4e0d\u662f\u5f53\u524d\u72b6\u6001\u5c31\u53d8\u5316\u4e86&#xff0c;\u6240\u4ee5\u4f60\u5c31\u8be5\u5237\u65b0\u4e00\u4e0b\u7a97\u53e3\u6539\u53d8\u72b6\u6001 \u8fd9\u6837\u6211\u4eec\u5c31\u6709\u4e86\u57fa\u7840\u7684\u4ea4\u4e92\u754c\u9762\u548c\u4ea4\u4e92\u5904\u7406\u51fd\u6570\u4e86<\/p>\n<p>\u4f60\u53ef\u4ee5\u81ea\u5b9a\u4e49\u6d88\u606f\u5b8f\u5982\u4e0b<\/p>\n<p>#define ID_STATE\u00a0\u00a0 \u00a0 1 #define ID_TEXTLIST \u00a02 #define ID_SENDTEXT\u00a0\u00a0 \u00a0 3<\/p>\n<p> \u4f60\u4e5f\u53ef\u4ee5\u81ea\u5b9a\u4e49\u5904\u7406\u6d88\u606f\u51fd\u6570<\/p>\n<p>LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) \u63a5\u4e0b\u6765\u6211\u4eec\u8981\u505a\u7684\u662f\u7f51\u7edc\u901a\u4fe1\u90e8\u5206&#xff0c;\u6211\u4eec\u4f7f\u7528socket\u65b9\u5f0f\u53bb\u8fde\u63a5 1.\u521b\u5efa\u5957\u63a5\u5b57socket 2.sockaddr_in\u8bbe\u7f6e\u7aef\u53e3\u548cip 3.\u8fde\u63a5connect \u00a04.\u7ebf\u7a0b\u53d1\u9001send\u548c\u63a5\u6536\u5355\u72ec\u4e00\u4e2a\u7ebf\u7a0brecv&#xff08;\u4f1a\u963b\u585e\u7b49\u5f85\u63a5\u53d7\u5230\u6d88\u606f&#xff09;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb752\u6b21\u3002\u4e3a\u4e86\u719f\u6089\u73b0\u6709\u670d\u52a1\u5668\u7684\u67b6\u6784\uff0c\u7f51\u4e0a\u7684\u670d\u52a1\u5668\u5185\u5bb9\u8fc7\u4e8e\u590d\u6742\uff0c\u6211\u5c06\u82b1\u65f6\u95f4\u6574\u7406\u4e00\u4e9b\u670d\u52a1\u5668\u7684\u77e5\u8bc6\u5e76\u7528\u4ee3\u7801\u5408\u6ce8\u91ca\u7684\u5f62\u5f0f\u5c55\u73b0\u7ed9\u5927\u5bb6\u770b,\u6211\u4f1a\u628a\u6240\u6709\u4ee3\u7801\u653e\u5230\u6700\u4e0b\u9762\uff0c\u5982\u679c\u6709\u7591\u95ee\u5927\u5bb6\u53ef\u4ee5\u79c1\u4fe1\u6211\u63a5\u4e0b\u6765\u7684\u66f4\u65b0\uff0c\u6211\u5c06\u6211\u6240\u5b66\u4e60\u65b0\u5185\u5bb9\u878d\u5165\u5230\u65e7\u7684\u670d\u52a1\u5668\u91cc\u5b8c\u5584\u4ed6\u7684\u6027\u80fd\u548c\u62d3\u5c55\u4ed6\u7684\u529f\u80fd\uff0c\u6211\u4e5f\u4f1a\u5206\u4eab\u6211\u7684\u5b66\u4e60\u65b9\u6cd5<\/p>\n","protected":false},"author":2,"featured_media":14335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,371,43],"topic":[],"class_list":["post-14336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-371","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/14336.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb752\u6b21\u3002\u4e3a\u4e86\u719f\u6089\u73b0\u6709\u670d\u52a1\u5668\u7684\u67b6\u6784\uff0c\u7f51\u4e0a\u7684\u670d\u52a1\u5668\u5185\u5bb9\u8fc7\u4e8e\u590d\u6742\uff0c\u6211\u5c06\u82b1\u65f6\u95f4\u6574\u7406\u4e00\u4e9b\u670d\u52a1\u5668\u7684\u77e5\u8bc6\u5e76\u7528\u4ee3\u7801\u5408\u6ce8\u91ca\u7684\u5f62\u5f0f\u5c55\u73b0\u7ed9\u5927\u5bb6\u770b,\u6211\u4f1a\u628a\u6240\u6709\u4ee3\u7801\u653e\u5230\u6700\u4e0b\u9762\uff0c\u5982\u679c\u6709\u7591\u95ee\u5927\u5bb6\u53ef\u4ee5\u79c1\u4fe1\u6211\u63a5\u4e0b\u6765\u7684\u66f4\u65b0\uff0c\u6211\u5c06\u6211\u6240\u5b66\u4e60\u65b0\u5185\u5bb9\u878d\u5165\u5230\u65e7\u7684\u670d\u52a1\u5668\u91cc\u5b8c\u5584\u4ed6\u7684\u6027\u80fd\u548c\u62d3\u5c55\u4ed6\u7684\u529f\u80fd\uff0c\u6211\u4e5f\u4f1a\u5206\u4eab\u6211\u7684\u5b66\u4e60\u65b9\u6cd5\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/14336.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T13:08:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130823-68024ec762572.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14336.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/14336.html\",\"name\":\"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T13:08:24+00:00\",\"dateModified\":\"2025-04-18T13:08:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/14336.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/14336.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/14336.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/14336.html","og_locale":"zh_CN","og_type":"article","og_title":"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb752\u6b21\u3002\u4e3a\u4e86\u719f\u6089\u73b0\u6709\u670d\u52a1\u5668\u7684\u67b6\u6784\uff0c\u7f51\u4e0a\u7684\u670d\u52a1\u5668\u5185\u5bb9\u8fc7\u4e8e\u590d\u6742\uff0c\u6211\u5c06\u82b1\u65f6\u95f4\u6574\u7406\u4e00\u4e9b\u670d\u52a1\u5668\u7684\u77e5\u8bc6\u5e76\u7528\u4ee3\u7801\u5408\u6ce8\u91ca\u7684\u5f62\u5f0f\u5c55\u73b0\u7ed9\u5927\u5bb6\u770b,\u6211\u4f1a\u628a\u6240\u6709\u4ee3\u7801\u653e\u5230\u6700\u4e0b\u9762\uff0c\u5982\u679c\u6709\u7591\u95ee\u5927\u5bb6\u53ef\u4ee5\u79c1\u4fe1\u6211\u63a5\u4e0b\u6765\u7684\u66f4\u65b0\uff0c\u6211\u5c06\u6211\u6240\u5b66\u4e60\u65b0\u5185\u5bb9\u878d\u5165\u5230\u65e7\u7684\u670d\u52a1\u5668\u91cc\u5b8c\u5584\u4ed6\u7684\u6027\u80fd\u548c\u62d3\u5c55\u4ed6\u7684\u529f\u80fd\uff0c\u6211\u4e5f\u4f1a\u5206\u4eab\u6211\u7684\u5b66\u4e60\u65b9\u6cd5","og_url":"https:\/\/www.wsisp.com\/helps\/14336.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T13:08:24+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418130823-68024ec762572.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/14336.html","url":"https:\/\/www.wsisp.com\/helps\/14336.html","name":"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T13:08:24+00:00","dateModified":"2025-04-18T13:08:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/14336.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/14336.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/14336.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"c++\u670d\u52a1\u5668\u5b66\u4e60\u4ece\u96f6\u5f00\u59cb\uff1a\u7b2c\u4e00\u671f\u4f7f\u7528windows\u7684\u5efa\u8baeapi\u642d\u5efa\u7b80\u5355\u670d\u52a1\u5668\u548c\u5ba2\u6237\u7aef\u901a\u4fe1"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=14336"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/14336\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/14335"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=14336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=14336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=14336"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=14336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}