SetService function
Applies to: desktop apps only
The SetService function registers or removes from the registry a network service within one or more namespaces. The function can also add or remove a network service type within one or more namespaces.
Note The SetService function is obsolete. The functions detailed in Protocol-Independent Name Resolution provide equivalent functionality in Windows Sockets 2. For the convenience of Windows Sockets 1.1 developers, the reference material is as follows.
Syntax
INT SetService( __in DWORD dwNameSpace, __in DWORD dwOperation, __in DWORD dwFlags, __in LPSERVICE_INFO lpServiceInfo, __in_opt LPSERVICE_ASYNC_INFO lpServiceAsyncInfo, __out LPDWORD lpdwStatusFlags );
Parameters
- dwNameSpace [in]
-
The namespace, or a set of default namespaces, within which the function will operate.
Use one of the following constants to specify a namespace.
- dwOperation [in]
-
The operation that the function will perform. Use one of the following values to specify an operation:
Value Meaning - SERVICE_REGISTER
Register the network service with the namespace. This operation can be used with the SERVICE_FLAG_DEFER and SERVICE_FLAG_HARD bit flags.
- SERVICE_DEREGISTER
Remove from the registry the network service from the namespace. This operation can be used with the SERVICE_FLAG_DEFER and SERVICE_FLAG_HARD bit flags.
- SERVICE_FLUSH
Perform any operation that was called with the SERVICE_FLAG_DEFER bit flag set to one.
- SERVICE_ADD_TYPE
Add a service type to the namespace.
For this operation, use the ServiceSpecificInfo member of the SERVICE_INFO structure pointed to by lpServiceInfo to pass a SERVICE_TYPE_INFO_ABS structure. You must also set the ServiceType member of the SERVICE_INFO structure. Other SERVICE_INFO members are ignored.
- SERVICE_DELETE_TYPE
Remove a service type, added by a previous call specifying the SERVICE_ADD_TYPE operation, from the namespace.
- dwFlags [in]
-
A set of bit flags that modify the function's operation. You can set one or more of the following bit flags:
- lpServiceInfo [in]
-
A pointer to a SERVICE_INFO structure that contains information about the network service or service type.
- lpServiceAsyncInfo [in, optional]
-
Reserved for future use. Must be set to NULL.
- lpdwStatusFlags [out]
-
A set of bit flags that receive function status information. The following bit flag is defined:
Value Meaning - SET_SERVICE_ PARTIAL_SUCCESS
One or more namespace providers were unable to successfully perform the requested operation.
Return value
If the function fails, the return value is SOCKET_ERROR. To get extended error information, call GetLastError. GetLastError can return the following extended error value.
| Error code | Meaning |
|---|---|
|
The function tried to register a service that was already registered. |
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | SetServiceW (Unicode) and SetServiceA (ANSI) |
See also
Send comments about this topic to Microsoft
Build date: 4/24/2012