Windows 会话管理

这篇博客介绍了Windows操作系统中的会话管理,重点是通过一个简单的DLL(SessionManage)实现基本功能。文中包含SessionManage.h和SessionManage.cpp的源代码,并提供了一个测试程序来展示其运行效果。
摘要由CSDN通过智能技术生成

         Windows 下的一个会话管理的 dll,只提供了简单的功能。

SessionManage.h

#ifndef __SessionManage_h__
#define __SessionManage_h__

#ifdef	DLLEXPORT
#define	DLLAPI	__declspec(dllexport)
#else
#define	DLLAPI	__declspec(dllimport)
#endif

#include <Windows.h>
#include <tchar.h>
#include <WtsApi32.h>

#define NAMELEN			64

typedef unsigned int	uint;

typedef struct _my_wts_process_info {
	DWORD		_session_id;
	DWORD		_process_id;
	TCHAR		_process_name[NAMELEN];
	TCHAR		_domain_name[NAMELEN];
	TCHAR		_user_name[NAMELEN];
	SID			_sid;
} MY_WTS_PROCESS_INFO, *PMY_WTS_PROCESS_INFO;

class DLLAPI CSessionManage
{
public:
	CSessionManage			( LPTSTR lpszServerName = NULL );
	virtual ~CSessionManage	();

	int		GetSessions		( PWTS_SESSION_INFO pSessions, uint count );
	int		GetProcesses	( DWORD dwSessionId, PMY_WTS_PROCESS_INFO pProcesses, uint count );
	int		GetProcesses	( PMY_WTS_PROCESS_INFO pProcesses, uint count );
	BOOL	GetSessionUser	( DWORD dwSessionId, LPTSTR lpszUserName );

	BOOL	DisconnectSession	( DWORD dwSessionId, BOOL bWait );
	BOOL	DisconnectSession	( BOOL bWait );
	BOOL	LogoffSession		( DWORD dwSessionId, BOOL bWait );
	BOOL	LogoffSession		( BOOL bWait );
	BOOL	LogoffUser			( LPCTSTR lpszUserName, BOOL bWait );

protected:
	CSessionManage	( const CSessionManage& );
	CSessionManage& operator = ( const CSessionManage& );

	BOOL	OpenServer	( LPTSTR lpszServerName );
	void	CloseServer	();

private:
	LPTSTR		_server_name;
	HANDLE		_server_handle;
};

#endif // __SessionManag
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值