添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Avis aux experts des API,
je 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

petit lien sur la doc :
http://msdn.microsoft.com/library/en-us/termserv/termserv/wtsquerysessioninf
ormation.asp

merci d'avance

Xavier
Post by Xavier ROUQUIER
je 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
Ok, thx !!

voici mon code au final :

p1, pBytes, retval are entier long
fsWinStationName is ASCIIZ string on 128
ServerName is ASCIIZ string on 257
ServerName=NetNomMachine()
hServer est un entier long =
AppelDll32("WTSAPI32","WTSOpenServerA",&ServerName)
Multitask(1)
_dll est un entier long = chargedll("wtsapi32")
SI _dll ALORS
IF hServer THEN
retval=AppelDll32("WTSAPI32","WTSQuerySessionInformationA",hServer,-1,6,&p
1,&pBytes)
IF retval THEN
IF pBytes>0 THEN
Transfer(&fsWinStationName,p1,pBytes)
END
AppelDll32("WTSAPI32","WTSFreeMemory",p1)
p1=0
END
AppelDll32("WTSAPI32","WTSCloseServer",hServer)
END
FIN
dechargedll(_dll)
trace(fsWinStationName)
Post by Peter
Post by Xavier ROUQUIER
je 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
(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
file://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)
file://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) file://redim array of WTS_SESSION_INFO
structures
Transfer(&dynarrSessionInfo,p,12*pCount) file://12 = size of 1
WTS_SESSION_INFO structure
END
API("WTSAPI32","WTSFreeMemory",p)
FOR i = 1 TO pCount
retval=API("WTSAPI32","WTSQuerySessionInformationA",hServer,dynarrSessionInf
o[i]:SessionID,6,&p1,&pBytes)
Post by Peter
file://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,arrSessi
onStates[dynarrSessionInfo[i]:State
Post by Peter
+ 1])
END
END
API("WTSAPI32","WTSCloseServer",hServer)
END
FreeDLL(liDLLHandle)
***
--
Peter
réponses Quelle est la différence entre le meilleur taux de montée et le taux de montée maximal? démarré 2014-08-27 21:43:56 UTC réponses Puisqu'il n'y a pas de toilettes sur les petits avions, comment gérez-vous l'inévitable? démarré 2017-05-05 04:00:53 UTC réponses Pourquoi les pilotes utilisent-ils les voies aériennes au lieu de «voler directement» à chaque fois? démarré 2015-01-06 05:30:59 UTC