• 大小: 5.44MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-10-15
  • 语言: C/C++
  • 标签: MFC  聊天  文件传送  

资源简介

能实现局域网内的点对点聊天,同时能实现局域网内文件传送。

资源截图

代码片段和文件信息

// Chat.cpp : Defines the class behaviors for the application.
//

#include “stdafx.h“
#include “Chat.h“
#include “ChatDlg.h“
#include 
#pragma comment(lib “Ws2_32.lib“)

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CChatApp

BEGIN_MESSAGE_MAP(CChatApp CWinApp)
//{{AFX_MSG_MAP(CChatApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
//    DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP CWinApp::onhelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChatApp construction

CChatApp::CChatApp()
{
// TODO: add construction code here
// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CChatApp object

CChatApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CChatApp initialization

BOOL CChatApp::InitInstance()
{
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
    
//******加载同步套接字库

    /*WORD wVersionRequested1;
WSADATA wsaData1;
int err1;
    wVersionRequested1=MAKEWORD(11);
    err1=WSAStartup(wVersionRequested1&wsaData1);
if(err1!=0)
{
return FALSE;
}

if(LOBYTE(wsaData1.wVersion)!=2||HIBYTE(wsaData1.wVersion)!=2)
{
WSACleanup();
return FALSE;
}*/

//**********

//*******加载异步套接字库

WORD wVersionRequested;
WSADATA wsaData;
int err;
    wVersionRequested=MAKEWORD(22);
    err=WSAStartup(wVersionRequested&wsaData);
if(err!=0)
{
return FALSE;
}

if(LOBYTE(wsaData.wVersion)!=2||HIBYTE(wsaData.wVersion)!=2)
{
WSACleanup();
return FALSE;
}
    //******************


CChatDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}


// Since the dialog has been closed return FALSE so that we exit the
//  application rather than start the application‘s message pump.
return FALSE;
}

CChatApp::~CChatApp()
{
WSACleanup();
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-07-19 19:27  Chat\
     文件        3582  2011-07-12 16:15  Chat\1.ICO
     文件        1270  2011-07-18 20:12  Chat\bitmap1.bmp
     文件       43972  2011-07-19 21:26  Chat\Chat.aps
     文件        1402  2011-07-20 15:10  Chat\Chat.clw
     文件        2850  2011-07-19 20:49  Chat\Chat.cpp
     文件        4369  2011-07-19 15:54  Chat\Chat.dsp
     文件         514  2011-07-18 21:08  Chat\Chat.dsw
     文件        1325  2011-07-19 20:49  Chat\Chat.h
     文件       74752  2011-07-20 15:11  Chat\Chat.ncb
     文件       56832  2011-07-20 15:11  Chat\Chat.opt
     文件         685  2011-07-20 14:58  Chat\Chat.plg
     文件        6361  2011-07-19 21:26  Chat\Chat.rc
     文件       16841  2011-07-20 14:58  Chat\ChatDlg.cpp
     文件        2461  2011-07-19 21:44  Chat\ChatDlg.h
     文件        1790  2011-07-12 21:49  Chat\color.ico
     目录           0  2011-07-19 19:27  Chat\Debug\
     文件     5555200  2011-07-20 14:58  Chat\Debug\Chat.bsc
     文件      127015  2011-07-20 14:58  Chat\Debug\Chat.exe
     文件      387884  2011-07-20 14:58  Chat\Debug\Chat.ilk
     文件       14065  2011-07-19 21:45  Chat\Debug\Chat.obj
     文件     7117276  2011-07-19 15:41  Chat\Debug\Chat.pch
     文件      451584  2011-07-20 14:58  Chat\Debug\Chat.pdb
     文件       10124  2011-07-19 21:27  Chat\Debug\Chat.res
     文件           0  2011-07-19 21:45  Chat\Debug\Chat.sbr
     文件       56896  2011-07-20 14:58  Chat\Debug\ChatDlg.obj
     文件           0  2011-07-20 14:58  Chat\Debug\ChatDlg.sbr
     文件      111613  2011-07-19 15:41  Chat\Debug\StdAfx.obj
     文件     1413974  2011-07-19 15:41  Chat\Debug\StdAfx.sbr
     文件      222208  2011-07-20 14:58  Chat\Debug\vc60.idb
     文件      380928  2011-07-20 14:58  Chat\Debug\vc60.pdb
............此处省略8个文件信息

评论

共有 条评论