WTS_INFO_CLASS enumeration

Contains values that indicate the type of session information to retrieve in a call to theWTSQuerySessionInformation function.

Syntax

C++
typedef  enum
_WTS_INFO_CLASS {
  WTSInitialProgram         = 0,
  WTSApplicationName        = 1,
  WTSWorkingDirectory       = 2,
  WTSOEMId                  = 3,
  WTSSessionId              = 4,
  WTSUserName               = 5,
  WTSWinStationName         = 6,
  WTSDomainName             = 7,
  WTSConnectState           = 8,
  WTSClientBuildNumber      = 9,
  WTSClientName             = 10,
  WTSClientDirectory        = 11,
  WTSClientProductId        = 12,
  WTSClientHardwareId       = 13,
  WTSClientAddress          = 14,
  WTSClientDisplay          = 15,
  WTSClientProtocolType     = 16,
  WTSIdleTime               = 17,
  WTSLogonTime              = 18,
  WTSIncomingBytes          = 19,
  WTSOutgoingBytes          = 20,
  WTSIncomingFrames         = 21,
  WTSOutgoingFrames         = 22,
  WTSClientInfo             = 23,
  WTSSessionInfo            = 24,
  WTSSessionInfoEx          = 25,
  WTSConfigInfo             = 26,
  WTSValidationInfo         = 27,
  WTSSessionAddressV4       = 28,
  WTSIsRemoteSession        = 29
} WTS_INFO_CLASS;
 

Constants

WTSInitialProgram

A null-terminated string that contains the name of the initial program that Remote Desktop Services runs when the user logs on.

WTSApplicationName

A null-terminated string that contains the published name of the application that the session is running.

WTSWorkingDirectory

A null-terminated string that contains the default directory used when launching the initial program.

WTSOEMId

This value is not used.

WTSSessionId

ULONG value that contains the session identifier.

WTSUserName

A null-terminated string that contains the name of the user associated with the session.

WTSWinStationName

A null-terminated string that contains the name of the Remote Desktop Services session.

Note  Despite its name, specifying this type does not return the window station name. Rather, it returns the name of the Remote Desktop Services session. Each Remote Desktop Services session is associated with an interactive window station. Because the only supported window station name for an interactive window station is "WinSta0", each session is associated with its own "WinSta0" window station. For more information, see Window Stations.

WTSDomainName

A null-terminated string that contains the name of the domain to which the logged-on user belongs.

WTSConnectState

The session's current connection state. For more information, see WTS_CONNECTSTATE_CLASS.

WTSClientBuildNumber

ULONG value that contains the build number of the client.

WTSClientName

A null-terminated string that contains the name of the client.

WTSClientDirectory

A null-terminated string that contains the directory in which the client is installed.

WTSClientProductId

USHORT client-specific product identifier.

WTSClientHardwareId

ULONG value that contains a client-specific hardware identifier. This option is reserved for future use. WTSQuerySessionInformation will always return a value of 0.

WTSClientAddress

The network type and network address of the client. For more information, seeWTS_CLIENT_ADDRESS.

The IP address is offset by two bytes from the start of the Address member of theWTS_CLIENT_ADDRESS structure.

WTSClientDisplay

Information about the display resolution of the client. For more information, seeWTS_CLIENT_DISPLAY.

WTSClientProtocolType

USHORT value that specifies information about the protocol type for the session. This is one of the following values.

ValueMeaning

0

The console session.

1

This value is retained for legacy purposes.

2

The RDP protocol.

 

WTSIdleTime

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSLogonTime

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSIncomingBytes

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSOutgoingBytes

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSIncomingFrames

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSOutgoingFrames

This value returns FALSE. If you call GetLastError to get extended error information,GetLastError returns ERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not used.
WTSClientInfo

Information about a Remote Desktop Connection (RDC) client. For more information, seeWTSCLIENT.

Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported. This value is supported beginning with Windows Server 2008 and Windows Vista with SP1.
WTSSessionInfo

Information about a client session on an RD Session Host server. For more information, seeWTSINFO.

Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported. This value is supported beginning with Windows Server 2008 and Windows Vista with SP1.
WTSSessionInfoEx

Extended information about a session on an RD Session Host server. For more information, seeWTSINFOEX.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported.
WTSConfigInfo

Information about the configuration of an RD Session Host server.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported.
WTSValidationInfo

This value is not supported.

WTSSessionAddressV4

WTS_SESSION_ADDRESS structure that contains the IPv4 address assigned to the session. If the session does not have a virtual IP address, the WTSQuerySessionInformation function returnsERROR_NOT_SUPPORTED.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported.
WTSIsRemoteSession

Determines whether the current session is a remote session. The WTSQuerySessionInformationfunction returns a value of TRUE to indicate that the current session is a remote session, andFALSE to indicate that the current session is a local session. This value can only be used for the local machine, so the hServer parameter of the WTSQuerySessionInformation function must contain WTS_CURRENT_SERVER_HANDLE.

Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not supported.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wtsapi32.h
 
 
 

Window Stations

 

window station contains a clipboard, an atom table, and one or more desktop objects. Each window station object is a securable object. When a window station is created, it is associated with the calling process and assigned to the current session.

The interactive window station is the only window station that can display a user interface or receive user input. It is assigned to the logon session of the interactive user, and contains the keyboard, mouse, and display device. It is always named "WinSta0". All other window stations are noninteractive, which means they cannot display a user interface or receive user input.

When a user logs on to a computer using Remote Desktop Services, a session is started for the user. Each session is associated with its own interactive window station named "WinSta0". For more information, see Remote Desktop Sessions.

 

WTS_CONNECTSTATE_CLASS enumeration  

1 out of 4 rated this helpful  Rate this topic

Specifies the connection state of a Remote Desktop Services session.

Syntax

C++
typedef  enum
_WTS_CONNECTSTATE_CLASS {
  WTSActive,
  WTSConnected,
  WTSConnectQuery,
  WTSShadow,
  WTSDisconnected,
  WTSIdle,
  WTSListen,
  WTSReset,
  WTSDown,
  WTSInit
} WTS_CONNECTSTATE_CLASS;
 

Constants

WTSActive

A user is logged on to the WinStation.

WTSConnected

The WinStation is connected to the client.

WTSConnectQuery

The WinStation is in the process of connecting to the client.

WTSShadow

The WinStation is shadowing another WinStation.

WTSDisconnected

The WinStation is active but the client is disconnected.

WTSIdle

The WinStation is waiting for a client to connect.

WTSListen

The WinStation is listening for a connection. A listener session waits for requests for new client connections. No user is logged on a listener session. A listener session cannot be reset, shadowed, or changed to a regular client session.

WTSReset

The WinStation is being reset.

WTSDown

The WinStation is down due to an error.

WTSInit

The WinStation is initializing.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wtsapi32.h

See also

WTS_SESSION_INFO WTSQuerySessionInformation WTSWaitSystemEvent

 

WTS_CLIENT_ADDRESS structure (Windows)

0 out of 1 rated this helpful Rate this topic

Contains the client network address of a Remote Desktop Services session.

Syntax

C++
typedef  struct
_WTS_CLIENT_ADDRESS {
  DWORD AddressFamily;
  BYTE  Address[20];
} WTS_CLIENT_ADDRESS, *PWTS_CLIENT_ADDRESS;
 

Members

AddressFamily

Address family. This member can be AF_INET, AF_INET6, AF_IPX, AF_NETBIOS, or AF_UNSPEC.

Windows Server 2003 and Windows XP:  This member can be AF_INET, AF_IPX, AF_NETBIOS, or AF_UNSPEC.
Address

Client network address.

Remarks

The client network address is reported by the RDP client itself when it connects to the server. This could be different than the address that actually connected to the server. For example, suppose there is a NAT between the client and the server. The client can report its own IP address, but the IP address that actually connects to the server is the NAT address. For VPN connections, the IP address might not be discoverable by the client. If it cannot be discovered, the client can report the only IP address it has, which may be the ISP assigned address. Because the address may not be the actual network address, it should not be used as a form of client authentication.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wtsapi32.h

See also

WTSQuerySessionInformation
 

WTS_CLIENT_DISPLAY structure (Windows)

0 out of 1 rated this helpful Rate this topic

Contains information about the display of a Remote Desktop Connection (RDC) client.

Syntax

C++
typedef  struct
_WTS_CLIENT_DISPLAY {
  DWORD HorizontalResolution;
  DWORD VerticalResolution;
  DWORD ColorDepth;
} WTS_CLIENT_DISPLAY, *PWTS_CLIENT_DISPLAY;
 

Members

HorizontalResolution

Horizontal dimension, in pixels, of the client's display.

VerticalResolution

Vertical dimension, in pixels, of the client's display.

ColorDepth

Color depth of the client's display. This member can be one of the following values.

ValueMeaning
1

4 bits per pixel.

2

8 bits per pixel.

4

16 bits per pixel.

8

A 3-byte RGB values for a maximum of 2^24 colors.

16

15 bits per pixel.

24

24 bits per pixel.

32

32 bits per pixel.

 

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wtsapi32.h

See also

WTSQuerySessionInformation 



本文转自 不得闲 博客园博客,原文链接:http://www.cnblogs.com/DxSoft/archive/2012/12/31/2840288.html    ,如需转载请自行联系原作者

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#include <windows.h> #include <QString> #include <QMessageBox> int main(int argc, char *argv[]) { HANDLE mutex = ::CreateMutex(Q_NULLPTR, true, (LPCWSTR)qApp->applicationName().toStdWString().c_str()); if (GetLastError() == ERROR_ALREADY_EXISTS) { QMessageBox waringBox(QMessageBox::Warning, QStringLiteral("警告"), QStringLiteral("当前程序已运行,不能再次运行!")); waringBox.setButtonText(QMessageBox::Ok, QStringLiteral("确定")); waringBox.setStandardButtons(QMessageBox::Ok); waringBox.exec(); ::CloseHandle(mutex); return 0; } // 获取当前登录用户的会话ID DWORD sessionId; ProcessIdToSessionId(GetCurrentProcessId(), &sessionId); // 遍历所有用户会话,关闭其他用户会话中的该程序进程 DWORD sessionCount; if (ProcessIdToSessionId(GetCurrentProcessId(), &sessionId) && WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTS_INFO_CLASS::WTS_SESSION, (LPWSTR*)&sessionCount, &sessionId)) { WTS_SESSION_INFO* pSessionInfo = NULL; if (WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo, &sessionCount)) { for (DWORD i = 0; i < sessionCount; i++) { DWORD processCount; if (WTSEnumerateProcesses(pSessionInfo[i].hServer, pSessionInfo[i].SessionId, 1, (PWTS_PROCESS_INFO*)&processCount)) { WTS_PROCESS_INFO* pProcessInfo = NULL; if (WTSEnumerateProcesses(pSessionInfo[i].hServer, pSessionInfo[i].SessionId, 1, &pProcessInfo, &processCount)) { for (DWORD j = 0; j < processCount; j++) { if (pProcessInfo[j].SessionId != sessionId && wcsstr(pProcessInfo[j].pProcessName, qApp->applicationName().toStdWString().c_str())) { HANDLE hProcess = ::OpenProcess(PROCESS_TERMINATE, FALSE, pProcessInfo[j].ProcessId); if (hProcess) { ::TerminateProcess(hProcess, 0); ::CloseHandle(hProcess); } } } ::WTSFreeMemory(pProcessInfo); } } } ::WTSFreeMemory(pSessionInfo); } } // 正常执行程序 QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } 上面代码会报出 error: 'WTS_CURRENT_SERVER_HANDLE' was not declared in this scope错误,请修复后给我完整代码
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值