c获取ip地址和主机名

上传人:xiao****1972 文档编号:84137717 上传时间:2019-03-02 格式:DOC 页数:4 大小:46.50KB
返回 下载 相关 举报
c获取ip地址和主机名_第1页
第1页 / 共4页
c获取ip地址和主机名_第2页
第2页 / 共4页
c获取ip地址和主机名_第3页
第3页 / 共4页
c获取ip地址和主机名_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《c获取ip地址和主机名》由会员分享,可在线阅读,更多相关《c获取ip地址和主机名(4页珍藏版)》请在金锄头文库上搜索。

1、C+获取IP地址和主机名一个简单的c+程序,用于获取主机名和IP地址。源码下载地址:http:/ 该程序通过自己的测试,能在visual c+ 6.0中完美运行。GetIP.cpp#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CGetIPAppBEGIN_MESSAGE_MAP(CGetIPApp, CWinApp)/AFX_MSG_MAP(CGetIPApp)/ NOTE - the ClassWizard will add and remove mapping

2、 macros here./ DO NOT EDIT what you see in these blocks of generated code!/AFX_MSGON_COMMAND(ID_HELP, CWinApp:OnHelp)END_MESSAGE_MAP()/ CGetIPApp constructionCGetIPApp:CGetIPApp()/ TODO: add construction code here,/ Place all significant initialization in InitInstance/ The one and only CGetIPApp obj

3、ectCGetIPApp theApp;/ CGetIPApp initializationBOOL CGetIPApp: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 sho

4、uld remove from the following/ the specific initialization routines you do not need.#ifdef _AFXDLLEnable3dControls();/ Call this when using MFC in a shared DLL#elseEnable3dControlsStatic();/ Call this when linking to MFC statically#endif CGetIPDlg dlg;m_pMainWnd = &dlg;int nResponse = dlg.DoModal();

5、if (nResponse = IDOK)/ TODO: Place code here to handle when the dialog is/ dismissed with OKelse if (nResponse = IDCANCEL)/ TODO: Place code here to handle when the dialog is/ dismissed with Cancel WSADATA wsaData;WSAStartup(MAKEWORD(1,1),&wsaData);/ Since the dialog has been closed, return FALSE so

6、 that we exit the/ application, rather than start the applications message pump.return FALSE;int CGetIPApp:ExitInstance() WSACleanup();return CWinApp:ExitInstance();GetIP.h/ GetIP.h : main header file for the GETIP application/#if !defined(AFX_GETIP_H_4F5A3E39_11E1_4654_A5DA_75F3810AD470_INCLUDED_)#

7、define AFX_GETIP_H_4F5A3E39_11E1_4654_A5DA_75F3810AD470_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000#ifndef _AFXWIN_H_#error include stdafx.h before including this file for PCH#endif#include resource.h/ main symbols/ CGetIPApp:/ See GetIP.cpp for the implementation of this class/clas

8、s CGetIPApp : public CWinApppublic:CGetIPApp();/ Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CGetIPApp)public:virtual BOOL InitInstance();virtual int ExitInstance();/AFX_VIRTUAL/ Implementation/AFX_MSG(CGetIPApp)/ NOTE - the ClassWizard will add and remove member functions here./ DO NOT EDIT what you see in these blocks of generated code !/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_GETIP_H_4F5A3E39_11E1_4654_A5DA_75F3810AD470_INCLUDED_)运行界面:

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号