1 function getcomputername: Obtain the NetBIOS Name of the local computer. This name is read from the registry at system startup. If the local computer is a node on the cluster computer, the name of the cluster virtual server is returned.
Bool getcomputername (lptstr lpbuffer, lpdword lpnsize)
2. The gethostname function obtains the name of the local computer.
Int gethostname (char * Name, int namelen );
3. The gethostbyname function obtains the corresponding "host" (with a name and address flag) from the host name database. Note that there may be multiple hosts, not just one
Struct hostent * far gethostbyname (const char * name)
4. The gethostbyaddr function can obtain the corresponding host (identified by the name and address) from the network address. Note that there may be multiple hosts rather than one
Struct hostent * far gethostbuaddr (const char * ADDR, int Len, int type)
5. Obtain the subnet mask of the computer.
The getadaptersinfo () function obtains the network information of the Local Computer and obtains the subnet mask of the computer.
Void ccomputernetbiosnamexdlg: oncomputernetbiosname ()
{
Wsadata;
Wsastartup (makeword (1, 1), & wsadata );
Char buffer [50];
DWORD nsize = strlen (buffer );
Getcomputername (buffer, & nsize );
Setdlgitemtext (idc_computernetbiosname, buffer );
Wsacleanup ();
}
Void ccomputernetbiosnamexdlg: onloadcomputername ()
{
Wsadata;
Wsastartup (makeword (1, 1), & wsadata );
Char name [50];
Gethostname (name, strlen (name ));
Setdlgitemtext (idc_loadcomputername, name );
Wsacleanup ();
}
Void ccomputernetbiosnamexdlg: oncomputer ()
{
Wsadata;
Wsastartup (makeword (1, 1), & wsadata );
Char name [50];
Gethostname (name, strlen (name ));
Struct hostent * phost;
Phost = gethostbyname (name );
Setdlgitemtext (idc_computer, phost-> h_name );
For (INT I = 0; phost! = NULL & phost-> h_addr_list [I]! = NULL; I ++)
{
Cstring STR;
STR = inet_ntoa (* (struct in_addr *) phost-> h_addr_list [I]);
M_list.addstring (STR );
}
Wsacleanup ();
}
Void ccomputernetbiosnamexdlg: ongethostbuaddr ()
{
Wsadata;
Wsastartup (makeword (1, 1), & wsadata );
DWORD dwipaddr;
Dwipaddr = inet_addr ("192.168.0.2 ");
Hostent * PHT;
PHT = gethostbyaddr (lpstr) & dwipaddr, 4, af_inet );
MessageBox (PHT-> h_name );
Wsacleanup ();
}