#include
#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) //可以獲取特定進(jìn)程
{
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);
}
創(chuàng)新互聯(lián)公司專注于歷下企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站,商城系統(tǒng)網(wǎng)站開發(fā)。歷下網(wǎng)站建設(shè)公司,為歷下等地區(qū)提供建站服務(wù)。全流程按需網(wǎng)站開發(fā),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)