ServiceClosePort (Windows CE 5.0)
This function closes the specified port listening on the super server.
BOOL ServiceClosePort(HANDLE hService, SOCKADDR* pSockAddr, int cbSockAddr, int iProtocol, BOOL fRemoveFromRegistry);
[in] Handle to the service instance of port to unbind.
[in] Pointer to the address of the port to stop listening on.
[in] Length of pSockAddr.
[in] Protocol of the socket to stop listening on.
[in] TRUE specifies that the registry key in HKEY_LOCAL_MACHINE\Services\ServiceName\Accept associated with this port should be deleted. Doing this causes the port to not be listened on the next time the service is loaded. Setting this value to FALSE means that, if the port information has been persisted to the registry, the next time the service is loaded this address will be listened on by Services.exe's super server.
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
This function provides granular control over which ports will no longer be listened on. The parameters pSockAddr, cbSockAddr, and iProtocol must match a currently open port's settings exactly or this function will fail and SetLastError to ERROR_SERVICE_CANNOT_ACCEPT_CTRL.
To close all sockets that are associated with a particular service, call ServiceUnbindPorts.
OS Versions: Windows CE .NET 4.1 and later.
Link Library: Coredll.lib.
Send Feedback on this topic to the authors