1 添加 #include <afxsock.h>
2 在OnInitDialog()中添加
if (!AfxSocketInit()){AfxMessageBox(_T("Windows 通信端口初始化失败"));return FALSE;}