亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? serverprogramdlg.cpp

?? Client 和Server 配套的網(wǎng)絡(luò)連接程序。
?? CPP
?? 第 1 頁 / 共 2 頁
字號(hào):
// ServerProgramDlg.cpp : implementation file
// Copyright (c) 2002
// 
// Written by: Jeff Miles
// Email: jeffmiles99@hotmail.com
//
// Thank you to both Adam Clauss for his IniFile class, and
// Chris Maunder and Warren Young for their System Tray work.
//
// This program is the Server portion to a complete
// Client/Server framework.  Feel free to use this framework
// as the basis for your network application. If you do use
// this framework, please let me know via e-mail.
//
// Since this program has not been extensively tested, expect bugs.
// Please e-mail me any suggestions or bugs that you find, or better
// yet, any modifications that you have made that adds to this programs
// functionality or efficiency.
//
// ***THIS VERSION FIXED THE FOLLOWING TWO BUGS IN VERSION 1.0***
// Known Bug: The Server Program does not compile in Debug mode.
//            Use Release mode instead.
//
// Known Bug: The Server Program's Exit button does not function correctly.
//            Use the "Shut Down Server" button instead.
//


#include "stdafx.h"
#include "ServerProgram.h"
#include "ServerProgramDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CServerProgramDlg dialog

//This block of code is necessary for the System Tray functionality
const char* kpcTrayNotificationMsg_ = "Server tray notification";
CServerProgramDlg::CServerProgramDlg(CWnd* pParent) : 
CDialog(CServerProgramDlg::IDD, pParent),
bMinimized_(false),
pTrayIcon_(0),
nTrayNotificationMsg_(RegisterWindowMessage(kpcTrayNotificationMsg_))

{
	//{{AFX_DATA_INIT(CServerProgramDlg)
	m_nTotalUsers = _T("");
	m_nUsersOnline = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CServerProgramDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CServerProgramDlg)
	DDX_Control(pDX, IDC_USERS, m_Users);
	DDX_Text(pDX, IDC_TOTALUSERS, m_nTotalUsers);
	DDX_Text(pDX, IDC_ONLINEUSERS, m_nUsersOnline);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CServerProgramDlg, CDialog)
	//{{AFX_MSG_MAP(CServerProgramDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_SETTINGS, OnSettings)
	ON_BN_CLICKED(IDC_VIEWLOG, OnViewlog)
	ON_BN_CLICKED(IDOK, OnExitServer)
	ON_BN_CLICKED(IDC_VIEWUSERS, OnViewusers)
	ON_WM_TIMER()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_RECEIVE_MESSAGE,OnReceiveMessage)
	ON_MESSAGE(WM_USER_EXIT,OnUserDisconnect)
	ON_MESSAGE(WM_USER_CONNECT,OnUserConnect)
	ON_COMMAND(IDC_ST_RESTORE, OnSTRestore)
	ON_COMMAND(IDC_ST_EXIT, OnSTExit)
END_MESSAGE_MAP()

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// The following block is necessary for the System Tray functionality
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

//// SetupTrayIcon /////////////////////////////////////////////////////
// If we're minimized, create an icon in the systray.  Otherwise, remove
// the icon, if one is present.

void CServerProgramDlg::SetupTrayIcon()
{
	if (bMinimized_ && (pTrayIcon_ == 0)) {
		pTrayIcon_ = new CSystemTray;
		pTrayIcon_->Create(0, nTrayNotificationMsg_, "Total Users Connected: " + m_nTotalUsers + " Users Currently Online: " + m_nUsersOnline,
							m_hIcon, IDR_SYSTRAY_MENU);
	}
	else {
		delete pTrayIcon_;
		pTrayIcon_ = 0;
	}
}

//// SetupTaskBarButton ////////////////////////////////////////////////
// Show or hide the taskbar button for this app, depending on whether
// we're minimized right now or not.

void CServerProgramDlg::SetupTaskBarButton()
{
	// Show or hide this window appropriately
	if (bMinimized_) {
		ShowWindow(SW_HIDE);
	}
	else {
		ShowWindow(SW_SHOW);
	}
}

void CServerProgramDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	// Decide if minimize state changed
	bool bOldMin = bMinimized_;
	if (nID == SC_MINIMIZE) {
		bMinimized_ = true;
	}
	else if (nID == SC_RESTORE) {
		bMinimized_ = false;
	}

	CDialog::OnSysCommand(nID, lParam);

	if (bOldMin != bMinimized_) {
		// Minimize state changed.  Create the systray icon and do 
		// custom taskbar button handling.
		if (bSystemTray)
		{
			SetupTrayIcon();
			SetupTaskBarButton();
		}
	}
}

void CServerProgramDlg::OnSTExit()
{
	OnCancel();
}

void CServerProgramDlg::OnSTRestore()
{
	ShowWindow(SW_RESTORE);
	bMinimized_ = false;
	SetupTrayIcon();
	SetupTaskBarButton();
}

BOOL CServerProgramDlg::DestroyWindow() 
{
 	// Get rid of systray icon
 	bMinimized_ = false;
 	SetupTrayIcon();
 	return CDialog::DestroyWindow();
}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// End of System Tray Code /////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// The following block is Created by MFC and has not been modified at all.
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CServerProgramDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CServerProgramDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// End of MFC Block ////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

BOOL CServerProgramDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	//This block of code is necessary for the System Tray functionality
	if (::AfxGetApp()->m_nCmdShow & SW_MINIMIZE) {
	// User wants app to start minimized, but that only affects the 
	// main window.  So, minimize this window as well.
	PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
	}

	//This code prevents two instances of the server from being created.
	//(The second instance will exit immediately)
	::SetProp(AfxGetMainWnd()->GetSafeHwnd(),"MYSERVER",(HANDLE)1);
	CreateMutex(NULL, TRUE, "MYSERVER");
	if(GetLastError() == ERROR_ALREADY_EXISTS)
	{
		::PostQuitMessage(-1);
		return FALSE;
	}

	//The following code sets up the list control in the main dialog
	m_Users.SetExtendedStyle( m_Users.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
	m_Users.InsertColumn(0,"Name",LVCFMT_LEFT,121,0);
    m_Users.InsertColumn(1,"Socket Number",LVCFMT_LEFT,100,0);
    m_Users.InsertColumn(2,"Version",LVCFMT_LEFT,65,0);
	m_Users.InsertColumn(3,"Password",LVCFMT_LEFT,117,0);
	m_Users.InsertColumn(4,"IP Address",LVCFMT_LEFT,90,0);

	//Sets the total number of users and current number of users online statistic to 0
	nUsersOnline = 0;
	nTotalUsers = 0;
	m_nUsersOnline = "0";
	m_nTotalUsers = "0";
	UpdateData(false);

	//Reads the saved server settings which are stored in the registry (so that you don't have
	//to reselect each option each time you run the server).
	ReadSettings();

	//if User Logging is enabled, this code creates the file if it doesn't already exist.
	if (bLog)
	{
		if(log.m_pStream != NULL)
			log.Close();
		WIN32_FIND_DATA fData;
		HANDLE handle = FindFirstFile(LPCTSTR(logPath),&fData); 
		if (handle == INVALID_HANDLE_VALUE)
		{
			if (log.Open (logPath, CFile::modeCreate | CFile::modeWrite) == TRUE)
				if(log.m_pStream != NULL)
					log.Close();
		}
	}

	//This runs the OnTimer User Maintenance function once per day
	SetTimer(1,86400000,NULL);		

	//If you require users to enter their password to log on, this code readies the user file (which contains their passwords) for later.
	if (bPassword)
	{
		usersFile.SetPath(userFilePath);
		usersFile.ReadFile();
	}

	//First Socket of the array to use.
	nextAvailableSocket = 0;

	//This code readies all 1000 sockets.  It informs each socket that they should send their messages to this class,
	//as well as it informs each socket of what socket number they are.
	for (int nSock=0;nSock<1000;nSock++)
	{
		Sock[nSock].hParent = m_hWnd;
		Sock[nSock].nSocket = nSock;
	}
	//Same as above, but for the socket that listens for incoming connections (when that happens, it passes the
	//connection to the next in line of the 1000 sockets.
	listenSock.hParent = m_hWnd;
	
	//Start 'er up!
	StartServer();

	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CServerProgramDlg::StartServer()
{
	//Create and start listening for connections
	if (listenSock.Create(nPort) && listenSock.Listen())
	{
		//If User logging is enabled, this code logs the starting up of the server.
		if (bLog)
		{
			if(log.m_pStream != NULL)
				log.Close();
			if (log.Open (logPath, CFile::modeWrite) == TRUE)
			{
				GetLocalTime(&st);
				GetTimeFormat(LOCALE_USER_DEFAULT,DATE_LONGDATE,&st,NULL,szTime,80);
				GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szDate, 80);
				char strPort[10];
				_itoa(nPort, strPort,10);
				log.SeekToEnd();
				log.WriteString("Server Started on "+CString(szDate)+" at "+CString(szTime)+" on Port "+strPort+"\n");
			}
		}
	}
}

//Called when a User Connects.  This function accepts the connection, and gets ready for the next connection.
//Once the connection is accepted, the client will attempt to log on (which has nothing to do with this function).
LRESULT CServerProgramDlg::OnUserConnect(WPARAM message,LPARAM nSocket)
{
	listenSock.Accept(Sock[nextAvailableSocket]);
	if (nextAvailableSocket==999)
		nextAvailableSocket=0;
	else
		nextAvailableSocket++;
	return (0);
}

//Called when a user sends their info to log on.
int CServerProgramDlg::UserLogOn(CString userName, CString userVersion, CString userPassword, int nSock)
{
	//If Version Checking is enabled, the user is booted off if they don't have the specified version.
	if (bVersionCheck)
	{
		if (userVersion != version)
			return -1;
	}

	//If Passwords are enabled, the user is booted off if they don't send their correct password.
	if (bPassword)
	{
		CString recordedUserPassword = usersFile.GetValue(userName,"Password");
		if (userPassword != recordedUserPassword)
			return -2;
	}
	
	//This code retrieves the users IP address.
	UINT nSize = 20;
	CString userIPAddress;
	Sock[nSock].GetPeerName(userIPAddress,nSize);
	
	//converts the users socket number to a string (so it can be inserted into the list control).
	char strSock[6];
	_itoa(nSock,strSock,10);

	//Add the user to the list control.
	m_Users.InsertItem(0,userName);
	m_Users.SetItemText(0,1,strSock);
	m_Users.SetItemText(0,2,userVersion);
	m_Users.SetItemText(0,3,userPassword);
	m_Users.SetItemText(0,4,userIPAddress);

	// If Password Checking is enabled, update the users file.
	if (bPassword)
	{
		usersFile.SetValue(userName,"Days Since Last Time Online","0");
		int timesOnline = usersFile.GetValueI(userName,"Number of Times Online");
		usersFile.SetValueI(userName,"Number of Times Online",timesOnline+1);
		usersFile.WriteFile();
	}

	//If User Logging is enabled, log this connection.
	if (bLog)
	{
		GetLocalTime(&st);
		GetTimeFormat(LOCALE_USER_DEFAULT,DATE_LONGDATE,&st,NULL,szTime,80);
		GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szDate, 80);
		log.SeekToEnd();
		log.WriteString(userName+" Connected On "+CString(szDate)+" at "+szTime+" from computer "+userIPAddress+"\n");
	}

	//Increases the total number of users and current number of users online statistic by one
	nUsersOnline++;
	nTotalUsers++;
	char strUsersOnline[8];
	char strTotalUsers[8];

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区电影在线观看| 成人免费视频caoporn| 精品99一区二区三区| 成人免费看的视频| 日韩精品一级二级| 一区在线播放视频| 欧美大片一区二区三区| 97se亚洲国产综合自在线不卡| 天天综合日日夜夜精品| 国产精品网站在线| 日韩欧美国产综合在线一区二区三区 | 国产成人精品亚洲777人妖| 亚洲精品国久久99热| 久久久久亚洲蜜桃| 日韩手机在线导航| 欧美午夜不卡在线观看免费| 不卡一区二区三区四区| 一本久道中文字幕精品亚洲嫩| 蜜桃视频在线一区| 午夜精品久久久久久久99水蜜桃| 国产精品美女久久久久aⅴ | 国产亚洲午夜高清国产拍精品| 欧美欧美午夜aⅴ在线观看| 99热精品一区二区| 处破女av一区二区| 国产成人亚洲精品青草天美| 精品一区二区三区在线观看国产| 亚洲第一成人在线| 亚洲免费观看高清完整| 亚洲欧美在线高清| 国产精品国产三级国产aⅴ中文| 日韩精品中文字幕在线不卡尤物| 欧美日产国产精品| 欧美日韩在线免费视频| 在线观看网站黄不卡| 91尤物视频在线观看| 成人av电影在线观看| 成人午夜短视频| 国产成人免费xxxxxxxx| 国产乱码字幕精品高清av| 极品少妇xxxx偷拍精品少妇| 久久精品久久99精品久久| 秋霞午夜鲁丝一区二区老狼| 日韩电影免费在线观看网站| 三级精品在线观看| 日本欧美一区二区| 毛片av一区二区三区| 美国十次了思思久久精品导航| 麻豆国产精品一区二区三区| 九一久久久久久| 国产乱码精品一区二区三区忘忧草 | 麻豆高清免费国产一区| 欧美亚洲动漫制服丝袜| 欧美日韩激情一区二区| 9191久久久久久久久久久| 91精品在线观看入口| 日韩一区二区精品葵司在线| 精品捆绑美女sm三区| 国产亚洲欧美色| 国产精品蜜臀在线观看| 亚洲综合视频在线| 日韩国产欧美在线视频| 国产一区二区调教| www.性欧美| 欧美日免费三级在线| 日韩写真欧美这视频| 国产日韩综合av| 亚洲欧美另类小说视频| 亚洲bt欧美bt精品777| 美腿丝袜一区二区三区| 成人免费视频一区| 欧美午夜精品久久久久久超碰| 日韩午夜在线观看| 亚洲国产精品精华液ab| 亚洲综合在线电影| 久久99久久久欧美国产| av不卡免费在线观看| 欧美伦理电影网| 国产午夜精品一区二区三区视频 | 色欧美乱欧美15图片| 欧美人伦禁忌dvd放荡欲情| 精品91自产拍在线观看一区| 亚洲欧洲另类国产综合| 日韩电影一区二区三区四区| 国产·精品毛片| 日本精品一区二区三区高清| 日韩一级黄色片| 国产精品家庭影院| 麻豆成人在线观看| 色婷婷av一区二区三区之一色屋| 日韩一区二区三| 亚洲啪啪综合av一区二区三区| 男男成人高潮片免费网站| 不卡影院免费观看| 日韩免费高清视频| 一区二区三区欧美视频| 91精品国产丝袜白色高跟鞋| 国产亚洲婷婷免费| 日韩黄色片在线观看| www.性欧美| 久久久五月婷婷| 天天色综合成人网| 91亚洲大成网污www| 久久一区二区三区四区| 亚洲大片精品永久免费| 99re这里只有精品6| 2020国产精品| 日韩vs国产vs欧美| 91极品美女在线| 国产精品蜜臀av| 精品一区二区免费视频| 欧美日韩一区二区欧美激情| 亚洲欧洲精品一区二区三区| 久久精工是国产品牌吗| 欧美猛男男办公室激情| 亚洲免费资源在线播放| 成人在线视频一区| 精品久久久网站| 日韩精品国产精品| 欧美影院精品一区| 亚洲欧洲精品一区二区三区| 国产一区二区三区不卡在线观看| 欧美一区二区三区喷汁尤物| 亚洲图片有声小说| 色哟哟在线观看一区二区三区| 日本一区二区三区免费乱视频 | www.亚洲激情.com| 国产午夜一区二区三区| 国产乱码精品一区二区三| 日韩欧美国产不卡| 男人的天堂久久精品| 欧美精三区欧美精三区| 午夜欧美电影在线观看| 欧美日韩在线精品一区二区三区激情 | 亚洲三级小视频| 日韩一卡二卡三卡| 免费观看久久久4p| 欧美一级高清片| 男人的j进女人的j一区| 日韩欧美电影在线| 精品在线播放免费| 亚洲精品在线观看视频| 精品一区二区三区视频| 欧美电影免费观看完整版| 韩国三级电影一区二区| 久久久精品一品道一区| 国产成人超碰人人澡人人澡| 日本一区二区电影| 91免费视频网| 亚洲一区免费观看| 欧美精品视频www在线观看 | 久久精品一区二区三区不卡 | 日韩福利电影在线观看| 538prom精品视频线放| 蜜臀久久99精品久久久久宅男 | 久久综合一区二区| 国产精品99久久久久| 国产精品初高中害羞小美女文| 91女神在线视频| 亚洲一区二区av电影| 欧美一区二区私人影院日本| 久久不见久久见免费视频7| 国产蜜臀av在线一区二区三区| 99视频在线精品| 亚洲自拍偷拍欧美| 日韩一区二区三区av| 国产黄色91视频| 亚洲精品乱码久久久久久久久| 色8久久人人97超碰香蕉987| 亚洲成a人v欧美综合天堂下载 | 欧美日韩黄色影视| 狠狠色综合日日| 综合久久综合久久| 4438成人网| 成人午夜免费电影| 午夜天堂影视香蕉久久| 日韩欧美国产高清| 91片在线免费观看| 日本中文在线一区| 国产精品毛片无遮挡高清| 欧美日韩不卡在线| 福利视频网站一区二区三区| 亚洲黄色片在线观看| 欧美xfplay| 日本精品视频一区二区| 久久精品免费观看| 激情综合网激情| 亚洲欧美日韩国产另类专区| 欧美成人bangbros| 91福利精品视频| 国产精品一区不卡| 天堂久久一区二区三区| 久久久久国色av免费看影院| 欧日韩精品视频| 国产成人在线看| 日本三级韩国三级欧美三级| 综合婷婷亚洲小说| 久久久噜噜噜久噜久久综合| 欧美久久婷婷综合色| 99精品国产一区二区三区不卡 |