DnsServiceRegister function (windns.h)

Used to register a discoverable service on this device.

Syntax

DWORD DnsServiceRegister(
  PDNS_SERVICE_REGISTER_REQUEST pRequest,
  PDNS_SERVICE_CANCEL           pCancel
);

Parameters

pRequest

A pointer to a DNS_SERVICE_REGISTER_REQUEST structure that contains information about the service to be registered.

pCancel

An optional (it can be nullptr) pointer to a DNS_SERVICE_CANCEL structure that can be used to cancel a pending asynchronous registration operation. If not nullptr, then this handle must remain valid until the registration is canceled.

Return value

If successful, returns DNS_REQUEST_PENDING; otherwise, returns the appropriate DNS-specific error code as defined in Winerror.h. For extended error information, call GetLastError.

Remarks

This function is asynchronous. The registration callback will be called once the registration succeeds. To deregister the service, call DnsServiceDeRegister.   The registration is tied to the lifetime of the calling process. If the process goes away, the service will be automatically deregistered.

Requirements

Requirement Value
Minimum supported client Windows 10 [desktop apps only]
Target Platform Windows
Header windns.h
Library dnsapi.lib
DLL dnsapi.dll