資源簡介
我知道VC6網絡編程有很多有趣的方法,但是我覺得適合新手學習的是Socket編程。本例子經我長期使用和調試,代碼簡單,注釋明了,希望大家喜歡。

代碼片段和文件信息
//?Client.cpp?:?Defines?the?class?behaviors?for?the?application.
//
#include?“stdafx.h“
#include?“Client.h“
#include?“MainFrm.h“
#include?“ClientDoc.h“
#include?“ClientView.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CClientApp
BEGIN_MESSAGE_MAP(CClientApp?CWinApp)
//{{AFX_MSG_MAP(CClientApp)
ON_COMMAND(ID_APP_ABOUT?OnAppAbout)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//????DO?NOT?EDIT?what?you?see?in?these?blocks?of?generated?code!
//}}AFX_MSG_MAP
//?Standard?file?based?document?commands
ON_COMMAND(ID_FILE_NEW?CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN?CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CClientApp?construction
CClientApp::CClientApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CClientApp?object
CClientApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CClientApp?initialization
BOOL?CClientApp::InitInstance()
{
if?(!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return?FALSE;
}
AfxEnableControlContainer();
//?Standard?initialization
//?If?you?are?not?using?these?features?and?wish?to?reduce?the?size
//??of?your?final?executable?you?should?remove?from?the?following
//??the?specific?initialization?routines?you?do?not?need.
#ifdef?_AFXDLL
Enable3dControls(); //?Call?this?when?using?MFC?in?a?shared?DLL
#else
Enable3dControlsStatic(); //?Call?this?when?linking?to?MFC?statically
#endif
//?Change?the?registry?key?under?which?our?settings?are?stored.
//?TODO:?You?should?modify?this?string?to?be?something?appropriate
//?such?as?the?name?of?your?company?or?organization.
SetRegistryKey(_T(“Local?AppWizard-Generated?Applications“));
LoadStdProfileSettings();??//?Load?standard?INI?file?options?(including?MRU)
//?Register?the?application‘s?document?templates.??Document?templates
//??serve?as?the?connection?between?documents?frame?windows?and?views.
CSingleDocTemplate*?pDocTemplate;
pDocTemplate?=?new?CSingleDocTemplate(
IDR_MAINframe
RUNTIME_CLASS(CClientDoc)
RUNTIME_CLASS(CMainframe)???????//?main?SDI?frame?window
RUNTIME_CLASS(CClientView));
AddDocTemplate(pDocTemplate);
//?Parse?command?line?for?standard?shell?commands?DDE?file?open
CCommandLineInfo?cmdInfo;
ParseCommandLine(cmdInfo);
//?Dispatch?commands?specified?on?the?command?line
if?(!ProcessShellCommand(cmdInfo))
return?FALSE;
//?The?one?and?only?window?has?been?initialized?so?show?and?update?it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return?TRUE;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-10-01?14:14??Socket編程.服務器支持多客戶端\
?????目錄???????????0??2013-10-01?16:07??Socket編程.服務器支持多客戶端\Client\
?????文件???????28156??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Client.aps
?????文件????????2487??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Client.clw
?????文件????????4208??2013-10-01?14:15??Socket編程.服務器支持多客戶端\Client\Client.cpp
?????文件????????4681??2013-10-01?15:45??Socket編程.服務器支持多客戶端\Client\Client.dsp
?????文件?????????537??2013-10-01?14:15??Socket編程.服務器支持多客戶端\Client\Client.dsw
?????文件????????1356??2013-10-01?14:15??Socket編程.服務器支持多客戶端\Client\Client.h
?????文件???????74752??2013-10-01?16:07??Socket編程.服務器支持多客戶端\Client\Client.ncb
?????文件???????50688??2013-10-01?16:07??Socket編程.服務器支持多客戶端\Client\Client.opt
?????文件????????4069??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Client.plg
?????文件???????11053??2013-10-01?15:44??Socket編程.服務器支持多客戶端\Client\Client.rc
?????文件????????1742??2013-10-01?14:15??Socket編程.服務器支持多客戶端\Client\ClientDoc.cpp
?????文件????????1475??2013-10-01?14:15??Socket編程.服務器支持多客戶端\Client\ClientDoc.h
?????文件????????4562??2013-10-01?15:26??Socket編程.服務器支持多客戶端\Client\ClientView.cpp
?????文件????????2029??2013-10-01?15:03??Socket編程.服務器支持多客戶端\Client\ClientView.h
?????目錄???????????0??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\
?????文件??????118857??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.exe
?????文件??????341792??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.ilk
?????文件???????23194??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.obj
?????文件?????5573712??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.pch
?????文件??????345088??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.pdb
?????文件????????6848??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\Client.res
?????文件???????14874??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\ClientDoc.obj
?????文件???????33398??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\ClientView.obj
?????文件???????15861??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\MainFrm.obj
?????文件????????8666??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\MySocket.obj
?????文件??????106699??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\StdAfx.obj
?????文件??????197632??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\vc60.idb
?????文件??????372736??2013-10-01?16:05??Socket編程.服務器支持多客戶端\Client\Debug\vc60.pdb
?????文件????????1569??2013-10-01?15:34??Socket編程.服務器支持多客戶端\Client\MainFrm.cpp
............此處省略80個文件信息
- 上一篇:MFC圖片預覽與縮放
- 下一篇:VC++單文檔視圖打開bmp圖片
評論
共有 條評論