internetconnection.cpp

来自「MFC 函数实用手册 MFC 函数实用手册」· C++ 代码 · 共 42 行

CPP
42
字号
// InternetConnection.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "InternetConnection.h"
#include "afxinet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// 唯一的应用程序对象

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// 初始化 MFC 并在失败时显示错误
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: 更改错误代码以符合您的需要
		_tprintf(_T("致命错误:MFC 初始化失败\n"));
		nRetCode = 1;
	}
	else
	{
		// TODO: 在此处为应用程序的行为编写代码。
		CInternetSession* pInetSesn = new CInternetSession();
		CInternetConnection* pInetConn = new CInternetConnection(pInetSesn, "www.scut.edu.cn");
		//DWORD_PTR dw = pInetConn->GetContext();
		CString szServerName = pInetConn->GetServerName();
		cout << "Server name is: " << (LPCTSTR)szServerName << endl;
	}
	getchar();
	return nRetCode;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?