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
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Peter
Xavier ROUQUIER wrote:
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
Xavier ROUQUIER wrote:
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)
***
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
Xavier ROUQUIER
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)
"Peter" a écrit dans le message de news: 40e3cf5b$0$57544$
Xavier ROUQUIER wrote:
> 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 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
file://6= WTSWinStationName fsWinStationName="" IF retval THEN IF pBytes>0 THEN Transfer(&fsWinStationName,p1,pBytes) END API("WTSAPI32","WTSFreeMemory",p1) p1=0 END
+ 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)
"Peter" <petervu_morethan100spamsadayistomuch_@xs4all.nl> a écrit dans le
message de news: 40e3cf5b$0$57544$e4fe514c@dreader9.news.xs4all.nl...
Xavier ROUQUIER wrote:
> 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
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
file://6= WTSWinStationName
fsWinStationName=""
IF retval THEN
IF pBytes>0 THEN
Transfer(&fsWinStationName,p1,pBytes)
END
API("WTSAPI32","WTSFreeMemory",p1)
p1=0
END
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)
"Peter" a écrit dans le message de news: 40e3cf5b$0$57544$
Xavier ROUQUIER wrote:
> 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 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
file://6= WTSWinStationName fsWinStationName="" IF retval THEN IF pBytes>0 THEN Transfer(&fsWinStationName,p1,pBytes) END API("WTSAPI32","WTSFreeMemory",p1) p1=0 END