WSAGetServiceClassInfoA function (winsock2.h)

The WSAGetServiceClassInfo function retrieves the class information (schema) pertaining to a specified service class from a specified namespace provider.


INT WSAAPI WSAGetServiceClassInfoA(
  LPGUID                 lpProviderId,
  LPGUID                 lpServiceClassId,
  LPDWORD                lpdwBufSize,



A pointer to a GUID that identifies a specific namespace provider.


A pointer to a GUID identifying the service class.


On input, the number of bytes contained in the buffer pointed to by the lpServiceClassInfo parameter.

On output, if the function fails and the error is WSAEFAULT, this parameter specifies the minimum size, in bytes, of the buffer pointed to lpServiceClassInfo needed to retrieve the record.


A pointer to a WSASERVICECLASSINFO structure that contains the service class information from the indicated namespace provider for the specified service class.

Return value

The return value is zero if the WSAGetServiceClassInfo was successful. Otherwise, the value SOCKET_ERROR is returned, and a specific error number can be retrieved by calling WSAGetLastError.

Error code Meaning
There was insufficient memory to perform the operation.
The calling routine does not have sufficient privileges to access the information.
The buffer pointed to by the lpServiceClassInfo parameter is too small to contain a WSASERVICECLASSINFOW. The application needs to pass in a larger buffer.
The specified service class identifier or namespace provider identifier is not valid. This error is returned if the lpProviderId, lpServiceClassId, lpdwBufSize, or lpServiceClassInfo parameters are NULL.
The operation is not supported for the type of object referenced. This error is returned by some namespace providers that do not support getting service class information.
The requested name is valid, but no data of the requested type was found.
The WS2_32.DLL has not been initialized. The application must first call WSAStartup before calling any Windows Sockets functions.
The specified class was not found.


The WSAGetServiceClassInfo function retrieves service class information from a namespace provider. The service class information retrieved from a particular namespace provider might not be the complete set of class information that was specified when the service class was installed. Individual namespace providers are only required to retain service class information that is applicable to the namespaces that they support. See the section Service Class Data Structures for more information.


The winsock2.h header defines WSAGetServiceClassInfo as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header winsock2.h
Library Ws2_32.lib
DLL Ws2_32.dll

See also

Service Class Data Structures




Winsock Functions

Winsock Reference