inet_ntoa
The Windows Sockets inet_ntoa function converts an (Ipv4) Internet network address into a string in Internet standard dotted format.
char FAR * inet_ntoa(
struct in_addr in
);
Parameters
in
[in] Structure that represents an Internet host address.
in_addr
The Windows Sockets in_addr structure represents a host by its Internet address.
struct in_addr {
union {
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
struct { u_short s_w1,s_w2; } S_un_w;
u_long S_addr;
} S_un;
};
Members
S_un_b
Address of the host formatted as four u_chars.
S_un_w
Address of the host formatted as two u_shorts.
S_addr
Address of the host formatted as a u_long.
你的理解是不正确的,ULONG的IP只是一个数值,具体怎么存放我也不知道,他和字符串形式的IP需要转换才能得到。
void CGetNameFromIPDlg::OnGet()
{
// TODO: Add your control notification handler code here
char m_strAddr[15];