WSCWriteProviderOrder function

The WSCWriteProviderOrder function is used to reorder the available transport providers. The order of the protocols determines the priority of a protocol when being enumerated or selected for use.


int WSPAPI WSCWriteProviderOrder(
  IN LPDWORD lpwdCatalogEntryId,
  IN DWORD   dwNumberOfEntries



A pointer to an array of CatalogEntryId elements found in the WSAPROTOCOL_INFO structure. The order of the CatalogEntryId elements is the new priority ordering for the protocols.


The number of elements in the lpwdCatalogEntryId array.

Return Value

The function returns ERROR_SUCCESS (zero) if the routine is successful. Otherwise, it returns a specific error code.

Error code Meaning
One or more of the arguments are invalid, no action was taken.
A nonrecoverable error occurred. This error is returned under several conditions including the following: the user lacks the administrative privileges required to write to the Winsock registry, or a failure occurred when opening or writing a catalog entry.
Insufficient memory was available. This error is returned when there is insufficient memory to allocate a new catalog entry.
The routine may return any registry error code.


The order in which transport service providers are initially installed governs the order in which they are enumerated through WSCEnumProtocols at the service provider interface, or through WSAEnumProtocols at the application interface. More importantly, this order also governs the order in which protocols and service providers are considered when a client requests creation of a socket based on its address family, type, and protocol identifier.

Windows Sockets 2 includes an application called Sporder.exe that allows the catalog of installed protocols to be reordered interactively after protocols have already been installed. Windows Sockets 2 also includes an auxiliary DLL, Sporder.dll that exports this procedural interface for reordering protocols. This interface can be imported by linking with Sporder.lib.

The following are scenarios in which the WSCWriteProviderOrder function could fail:

  • The dwNumberOfEntries parameter is not equal to the number of registered service providers.
  • The lpwdCatalogEntryId contains an invalid catalog identifier.
  • The lpwdCatalogEntryId does not contain all valid catalog identifiers exactly one time.
  • The routine is not able to access the registry for some reason (for example, inadequate user permissions).
  • Another process (or thread) is currently calling the function.

On success, WSCWriteProviderOrder will attempt to alert all interested applications that have registered for notification of the change by calling WSAProviderConfigChange.

The WSCWriteProviderOrder function can only be called by a user logged on as a member of the Administrators group. If WSCWriteProviderOrder is called by a user that is not a member of the Administrators group, the function call will fail and WSANO_RECOVERY is returned. For computers running on Windows Vista or Windows Server 2008, this function can also fail because of user account control (UAC). If an application that contains this function is executed by a user logged on as a member of the Administrators group other than the built-in Administrator, this call will fail unless the application has been marked in the manifest file with a requestedExecutionLevel set to requireAdministrator. If the application on Windows Vista or Windows Server 2008 lacks this manifest file, a user logged on as a member of the Administrators group other than the built-in Administrator must then be executing the application in an enhanced shell as the built-in Administrator (RunAs administrator) for this function to succeed.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header sporder.h
Library Sporder.lib
DLL Ws2_32.dll

See Also