⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdlg.cpp

📁 对齐的 bnnbc nccb
💻 CPP
字号:
// TestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AlignMode.h"
#include "TestDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestDlg dialog


CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestDlg)
	DDX_Control(pDX, IDC_IPADDRESS, m_ip);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
	//{{AFX_MSG_MAP(CTestDlg)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDlg message handlers
#include <afxcmn.h>
#include<stdio.h>  
#include<winsock2.h>
#pragma comment(lib,"ws2_32.lib")
void CheckIP(void) 
{
    WSADATA wsaData;
    char name[155];
    char *ip;
    PHOSTENT hostinfo; 
    if ( WSAStartup( MAKEWORD(2,0), &wsaData ) == 0 ) 
	{  
        if( gethostname ( name, sizeof(name)) == 0) 
		{ 
             if((hostinfo = gethostbyname(name)) != NULL) 
			 { //这些就是获得IP的函数
                  ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list); 

                  printf("%s\n",ip);
				  //CIPAddressCtrl::SetWindowText(IDC_IPADDRESS)=ip;
			 } 
		} 
     WSACleanup( );
	} 
}

int main(void)
{
    CheckIP();
    return 0;
}

⌨️ 快捷键说明

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