Post by Xavier ROUQUIERje cherche quelqu'un qui peut m'écrire un bou de code, pour récupérer l'id
de ma session TSE grace à WTSQuerySessionInformationA
en windev 55
WD75:
(dirty copy & paste, should work in wd55 with some change, int > long
int , API > CallDLL32 ..., & not exactly what you've asked for but...)
****
WTS_SESSION_INFO is structure
SessionId is int
pWinStationName is int
//state As WTS_CONNECTSTATE_CLASS
state is int
END
arrSessionStates is array fixed of 10 string
arrSessionStates[1]="Active"
arrSessionStates[2]="Connected"
arrSessionStates[3]="Query"
arrSessionStates[4]="Shadow"
arrSessionStates[5]="Disconnected"
arrSessionStates[6]="Idle"
arrSessionStates[7]="Listen"
arrSessionStates[8]="Reset"
arrSessionStates[9]="Down"
arrSessionStates[10]="Initialize"
liDLLHandle, hServer are int
pCount , p, p1, pBytes, retval, i, j are int
fsWinStationName is ASCIIZ string on 128
fsUserName is ASCIIZ string on 260
dynarrSessionInfo is array dynamic of 1 WTS_SESSION_INFO
ServerName is ASCIIZ string on 257
liDLLHandle = LoadDLL("WTSAPI32")
IF liDLLHandle > 0 THEN
ServerName="\\server"
hServer=API("WTSAPI32","WTSOpenServerA",&ServerName)
//hServer=API("WTSAPI32","WTSOpenServerA",WTS_CURRENT_SERVER_HANDLE)
Multitask(10)
IF hServer>0 THEN
retval=API("WTSAPI32","WTSEnumerateSessionsA",hServer,0,1,&p,&pCount)
IF NOT retval RETURN
IF pCount>0 THEN
Dimension(dynarrSessionInfo,pCount) //redim array of WTS_SESSION_INFO
structures
Transfer(&dynarrSessionInfo,p,12*pCount) //12 = size of 1
WTS_SESSION_INFO structure
END
API("WTSAPI32","WTSFreeMemory",p)
FOR i = 1 TO pCount
retval=API("WTSAPI32","WTSQuerySessionInformationA",hServer,dynarrSessionInfo[i]:SessionID,6,&p1,&pBytes)
//6= WTSWinStationName
fsWinStationName=""
IF retval THEN
IF pBytes>0 THEN
Transfer(&fsWinStationName,p1,pBytes)
END
API("WTSAPI32","WTSFreeMemory",p1)
p1=0
END
TableAddLine(Table1,dynarrSessionInfo[i]:SessionID,fsWinStationName,arrSessionStates[dynarrSessionInfo[i]:State
+ 1])
END
END
API("WTSAPI32","WTSCloseServer",hServer)
END
FreeDLL(liDLLHandle)
***
--
Peter