VC6.0中MFC向导选中Windows Sockets后,mfc向导会自动在建立的应用程序框架中加入winsocket初始化代码。如果我们需要在传统的串口通信程序加入网络通信的功能,就必须手工加入网络初始化代码。步骤如下。
1.加入winsocket初始化头文件
在stdafx.h中加入afxsock.h
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__71EE4E1B_9F80_4D8E_99A1_4B615AF25C9E__INCLUDED_)
#define AFX_STDAFX_H__71EE4E1B_9F80_4D8E_99A1_4B615AF25C9E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPO