#include <WtsApi32.h>
#pragma comment(lib,"WtsApi32.lib")
SID_NAME_USE sUse;
WTS_PROCESS_INFO *pProInfo,*pTemp;
DWORD dwRes;
DWORD dwSize = MAX_PATH;
WCHAR wzUserName[MAX_PATH];
WCHAR wzDomainName[MAX_PATH];
if(WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE,0,1,&pProInfo,&dwRes))
{
pTemp = pProInfo;
for (DWORD i = 0; i < dwRes;i ++)
{
//if (pTemp->ProcessId == dwProcess) //可以获取特定进程
{
if(LookupAccountSid(NULL,pTemp->pUserSid,wzUserName,&dwSize,wzDomainName,&dwSize,&sUse))
{
wprintf(_T("%d %d %s %s %s\r\n"),i,pTemp->ProcessId,pTemp->pProcessName,wzUserName,wzDomainName);
}
}
pTemp ++;
}
WTSFreeMemory(pProInfo);
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。