网站首页  词典首页

请输入您要查询的函数:

 

术语 netsessiondel
释义 NetSessionDel
语法:
C++
NET_API_STATUS NetSessionDel(
__in LPWSTR servername,
__in LPWSTR UncClientName,
__in LPWSTR username
);
NetSessionDel功能
与服务器和工作站完网络会话。
参数
服务器名 [in]
指针指向一个字符串,它指定的DNS或NetBIOS的远程服务器上的功能是执行的名称。如果该参数为NULL,则使用本地计算机。
UncClientName [in]
一个字符串指针,指定客户端计算机的名称断开。如果UncClientName参数为NULL,则所有的用户名参数确定的用户会话将被删除的服务器名由参数指定的服务器。有关更多信息,请参阅NetSessionEnum。
用户名 [in]
指针指向一个字符串指定用户的会话被终止的名称。如果该参数为NULL,我们从UncClientName参数指定的客户端的所有用户的会话将终止。
返回值
如果函数成功,返回值是NERR_Success。
如果函数失败,返回值可以是下面的错误代码之一。
返回codeDescription
ERROR_ACCESS_DENIEDThe用户没有获得所需的信息。
ERROR_INVALID_PARAMETERThe指定的参数无效。
ERROR_NOT_ENOUGH_MEMORYInsufficient内存可用。
NERR_ClientNameNotFoundA会话不存在与该计算机的名称。
备注
管理员或服务器操作员本地组的成员才可以成功地执行NetSessionDel功能。
如果您是Active Directory的程序,您可以调用某些Active Directory服务接口(ADSI)的方法来达到同样的功能,您可以通过调用实现网络管理会议的功能。有关更多信息,请参阅IADsSession和IADsFileServiceOperations。
实例
下面的代码示例演示如何终止之间的服务器和工作站使用调用NetSessionDel功能会议。
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "Netapi32.lib");
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwError = 0;
LPTSTR pszServerName = NULL;
LPTSTR pszClientName = NULL;
LPTSTR pszUserName = NULL;
NET_API_STATUS nStatus;
//
// Check command line arguments.
//
if (argc > 4)
{
wprintf(L"Usage: %s [\\\\\\\\ServerName] [\\\\\\\\ClientName] [UserName]\\n", argv[0]);
exit(1);
}
if (argc >= 2)
pszServerName = argv[1];
if (argc >= 3)
pszClientName = argv[2];
if (argc == 4)
pszUserName = argv[3];
//
// Call the NetSessionDel function to delete the session.
//
nStatus = NetSessionDel(pszServerName,
pszClientName,
pszUserName);
//
// Display the result of the 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;
}
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderLmshare.h(包括Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
参见
网络管理概述
网络管理功能
会话功能
NetSessionEnum
NetSessionGetInfo
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年7月30日
==英文原文==NetSessionDel Function
Ends a network session between a server and a workstation.
Syntax
C++
NET_API_STATUS NetSessionDel(
__in LPWSTR servername,
__in LPWSTR UncClientName,
__in LPWSTR username
);
Parameters
servername [in]
Pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the function is to execute. If this parameter is NULL, the local computer is used.
UncClientName [in]
Pointer to a string that specifies the computer name of the client to disconnect. If the UncClientName parameter is NULL, then all the sessions of the user identified by the username parameter will be deleted on the server specified by the servername parameter. For more information, see NetSessionEnum .
username [in]
Pointer to a string that specifies the name of the user whose session is to be terminated. If this parameter is NULL, all users' sessions from the client specified by the UncClientName parameter are to be terminated.
Return Value
If the function succeeds, the return value is NERR_Success.
If the function fails, the return value can be one of the following error codes.
Return codeDescription
ERROR_ACCESS_DENIEDThe user does not have access to the requested information.
ERROR_INVALID_PARAMETERThe specified parameter is not valid.
ERROR_NOT_ENOUGH_MEMORYInsufficient memory is available.
NERR_ClientNameNotFoundA session does not exist with that computer name.

Remarks
Only members of the Administrators or Server Operators local group can successfully execute the NetSessionDel function.
If you are programming for Active Directory, you may be able to call certain Active Directory Service Interface (ADSI) methods to achieve the same functionality you can achieve by calling the network management session functions. For more information, see IADsSession and IADsFileServiceOperations .
Examples
The following code sample demonstrates how to terminate a session between a server and a workstation using a call to the NetSessionDel function.
#ifndef UNICODE
#define UNICODE
#endif
#pragma comment(lib, "Netapi32.lib");
#include
#include
#include
int wmain(int argc, wchar_t *argv[])
{
DWORD dwError = 0;
LPTSTR pszServerName = NULL;
LPTSTR pszClientName = NULL;
LPTSTR pszUserName = NULL;
NET_API_STATUS nStatus;
//
// Check command line arguments.
//
if (argc > 4)
{
wprintf(L"Usage: %s [\\\\\\\\ServerName] [\\\\\\\\ClientName] [UserName]\\n", argv[0]);
exit(1);
}
if (argc >= 2)
pszServerName = argv[1];
if (argc >= 3)
pszClientName = argv[2];
if (argc == 4)
pszUserName = argv[3];
//
// Call the NetSessionDel function to delete the session.
//
nStatus = NetSessionDel(pszServerName,
pszClientName,
pszUserName);
//
// Display the result of the 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;
}
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderLmshare.h (include Lm.h)
LibraryNetapi32.lib
DLLNetapi32.dll
See Also
Network Management Overview
Network Management Functions
Session Functions
NetSessionEnum
NetSessionGetInfo
Send comments about this topic to Microsoft
Build date: 7/30/2009
==原始网址==http://msdn.microsoft.com/en-us/library/bb525381(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2025/1/8 11:00:40