Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

sethostname

Windows Mobile 6.5
A version of this page is also available for
4/8/2010

This function is used to register the host name on a network with the Windows Internet Naming Service (WINS). This function also sets HKEY_LOCAL_MACHINE\Ident\Name and registers the name with DNS and LLMNR.

Aa921126.note(en-us,MSDN.10).gifNote:
DHCP Option 12 behavior is affected in the following manner when HKEY_LOCAL_MACHINE\Ident\Name is not equal to HKEY_LOCAL_MACHINE\Ident\OrigName. If the device has a unique name, where Name is not equal to OrigName, then the device will send DHCP Option 12. If the device does not have a unique name, or if both Name and OrigName do not exist under the Ident key, then the device will not send DHCP Option 12.

int sethostname(
  char* pName,
  int cName
);
pName

[in] Pointer to the host name.

cName

[in] Length of the host name.

If no error occurs, this function returns zero. If an error occurs, this function returns a value of SOCKET_ERROR, and retrieves a specific error code by calling WSAGetLastError.

The following table shows possible error codes for this function.

Error code Description

WSAEFAULT

The name parameter is not a valid part of the user address space, or the buffer size specified by the cName parameter is too small to hold the complete host name.

WSAEINVAL

One of the parameters is invalid.

WSAENETDOWN

The network subsystem failed.

WSAEALREADY

The host already is the name specified.

SetHostName performs the following actions.

1. Verifies that the name follows WINS rules.

2. Updates the registry keys.

3. Signals notification_event_machine_name_change.

4. Informs the 3 following name registration facilities

Netbios/WINS

LLMNR

DNS

Headerwinsock2.h
LibraryWs2.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.