Platform SDK: Network Management |
Windows 95/98: The following code sample demonstrates how to terminate a session with a call to the NetSessionDel function.
#include <stdio.h> #include <windows.h> #include <svrapi.h> int main(int argc, char FAR * argv[]) { DWORD dwError = 0; char FAR * pszServerName = NULL; char FAR * pszClientName = NULL; short nSessionKey = -1; NET_API_STATUS nStatus; // // ServerName can be NULL to indicate the local computer. // if ((argc < 3) || (argc > 4)) { printf("Usage: %s ClientName SessionKey [\\\\ServerName]\n", argv[0]); printf("Note: ClientName is case sensitive\n"); exit(1); } pszClientName = argv[1]; nSessionKey = atoi(argv[2]); if (argc == 4) pszServerName = argv[3]; // // Call the NetSessionDel function to terminate the session. // nStatus = NetSessionDel(pszServerName, pszClientName, nSessionKey); // // Display the result of the function call. // if (nStatus == NERR_Success) fprintf(stderr, "The specified session(s) has been successfully deleted\n"); else fprintf(stderr, "A system error has occurred: %d\n", nStatus); return 0; }