資源簡(jiǎn)介
VC 獲取計(jì)算機(jī)名和IP地址,基于MFC的,是一個(gè)通過MFC來獲取本地計(jì)算機(jī)IP地址的程序。具體來說是使用gethostname獲取主機(jī)名(計(jì)算機(jī)名),使用GetIPAddress來獲取IP地址的字符串,然后再經(jīng)過字符轉(zhuǎn)換成IP格式,這個(gè)例子挺簡(jiǎn)單,對(duì)研究MFC的朋友,或許有幫助。
代碼片段和文件信息
//?IPAddress.cpp?:?Defines?the?class?behaviors?for?the?application.
//?Download?by?http://www.srcfans.com
#include?“stdafx.h“
#include?“IPAddress.h“
#include?“IPAddressDlg.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CIPAddressApp
BEGIN_MESSAGE_MAP(CIPAddressApp?CWinApp)
//{{AFX_MSG_MAP(CIPAddressApp)
//?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()
/////////////////////////////////////////////////////////////////////////////
//?CIPAddressApp?construction
CIPAddressApp::CIPAddressApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CIPAddressApp?object
CIPAddressApp?theApp;
/////////////////////////////////////////////////////////////////////////////
//?CIPAddressApp?initialization
BOOL?CIPAddressApp::InitInstance()
{
//?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
CIPAddressDlg?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;
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????4326??1998-07-08?17:16??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.001
?????文件??????21432??2002-12-17?22:27??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.aps
?????文件???????1229??2002-12-17?22:27??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.clw
?????文件???????2107??2016-12-01?17:36??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.cpp
?????文件???????4260??2002-08-09?09:09??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.dsp
?????文件????????541??2002-08-09?09:09??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.dsw
?????文件???????1365??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.h
?????文件???????5885??2002-11-20?11:49??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddress.rc
?????文件???????6546??2016-12-01?17:36??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddressDlg.cpp
?????文件???????1536??1998-07-08?16:19??srcfans.com\獲得本機(jī)ip地址的MFC程序\IPAddressDlg.h
?????文件???????3404??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\ReadMe.txt
?????文件???????1078??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\res\IPAddress.ico
?????文件????????401??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\res\IPAddress.rc2
?????文件????????733??1998-07-08?15:55??srcfans.com\獲得本機(jī)ip地址的MFC程序\resource.h
?????文件????????207??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\StdAfx.cpp
?????文件????????928??1998-07-08?15:38??srcfans.com\獲得本機(jī)ip地址的MFC程序\StdAfx.h
?????目錄??????????0??2016-12-01?17:35??srcfans.com\獲得本機(jī)ip地址的MFC程序\res
?????目錄??????????0??2016-12-01?17:35??srcfans.com\獲得本機(jī)ip地址的MFC程序
?????目錄??????????0??2016-12-01?17:35??srcfans.com
-----------?---------??----------?-----??----
????????????????55978????????????????????19
評(píng)論
共有 條評(píng)論