Wie viele Benutzer angemeldet
Wie viele Benutzer angemeldet
Mit welcher API kann ich herausbekommen, wie viele Benutzer am System angemeldet sind?
Die genaue Anzahl brauche "ich" nicht zu wissen. Mich interessiert nur, ob überhaupt ein
weiterer Benutzer angemeldet ist.
Die genaue Anzahl brauche "ich" nicht zu wissen. Mich interessiert nur, ob überhaupt ein
weiterer Benutzer angemeldet ist.
- NicTheQuick
- Ein Admin
- Beiträge: 8807
- Registriert: 29.08.2004 20:20
- Computerausstattung: Ryzen 7 5800X, 64 GB DDR4-3200
Ubuntu 24.04.2 LTS
GeForce RTX 3080 Ti - Wohnort: Saarbrücken
Re: Wie viele Benutzer angemeldet
Hilft dir das weiter? Oder wolltest du eine explizite API?
Useful commands for Windows administrators - Who is logged on to a computer?
Useful commands for Windows administrators - Who is logged on to a computer?
Re: Wie viele Benutzer angemeldet
Das ist eine sehr schöne Zusammenfassung der cmd-Befehle.
Ich brauche aber eine API, die mir die Anzahl der angemeldeten Benutzer zurück gibt.
Ich habe mittlerweile wahrscheinlich eine zutreffende Funktion unter
http://msdn.microsoft.com/en-us/library/aa383833.aspx entdeckt.
Aber wie bekomme ich das in PB "übersetzt"? Damit habe ich nach wie vor die meisten Probleme.
Ich brauche aber eine API, die mir die Anzahl der angemeldeten Benutzer zurück gibt.
Ich habe mittlerweile wahrscheinlich eine zutreffende Funktion unter
http://msdn.microsoft.com/en-us/library/aa383833.aspx entdeckt.
Aber wie bekomme ich das in PB "übersetzt"? Damit habe ich nach wie vor die meisten Probleme.
Re: Wie viele Benutzer angemeldet
NetWkstaUserEnumpurebas hat geschrieben:Mit welcher API kann ich herausbekommen, wie viele Benutzer am System angemeldet sind?
jpd hat dazu ein Code-Beispiel für Windows erstellt (und im späteren Verlauf des Threads auch, wie man das in Linux mit der API-Funktion getutent_() realisiert):
http://www.purebasic.fr/german/viewtopi ... =8&t=22831
Re: Wie viele Benutzer angemeldet
NetWkstaUserEnum gibt die Anzahl der angelegten Benutzerkonten zurück.
Ich benötige aber die Anzahl der zur Laufzeit eingeloggten Benutzer.
Stichwort: Schnelle Benutzerumschaltung
Unter XP habe ich die schnelle Benutzerumschaltung verteufelt, da die
meisten Programme nicht wirklich richtig angepasst waren. Ab Vista
hat sich dies aber deutlich verbessert. Wobei dies nicht unbedingt dem
System zugrundeliegt, sondern, die Softwareentwicklung die schnelle
Benutzerumschaltung mittlerweile gut berücksichtigt.
Privat nutze ich diese Umschaltung auch sehr intensiv, da ich mich nicht ständig
abmelden will, meine Programme starten will und meine Tochter und mein Sohn
wollen dies auch nicht. Der Rechner läuft einfach und am Abend geht es in den
Ruhemodus.
Ich benötige aber die Anzahl der zur Laufzeit eingeloggten Benutzer.
Stichwort: Schnelle Benutzerumschaltung
Unter XP habe ich die schnelle Benutzerumschaltung verteufelt, da die
meisten Programme nicht wirklich richtig angepasst waren. Ab Vista
hat sich dies aber deutlich verbessert. Wobei dies nicht unbedingt dem
System zugrundeliegt, sondern, die Softwareentwicklung die schnelle
Benutzerumschaltung mittlerweile gut berücksichtigt.
Privat nutze ich diese Umschaltung auch sehr intensiv, da ich mich nicht ständig
abmelden will, meine Programme starten will und meine Tochter und mein Sohn
wollen dies auch nicht. Der Rechner läuft einfach und am Abend geht es in den
Ruhemodus.
Re: Wie viele Benutzer angemeldet
Alternativ kannst du es über WMI ermitteln: http://stackoverflow.com/questions/8987 ... d-in-users
Es ist zwar VB/VBS, aber mit PB mit einer Include/Library kannst du WMI auch ansprechen. Ich habs aber nicht getestet.
Es ist zwar VB/VBS, aber mit PB mit einer Include/Library kannst du WMI auch ansprechen. Ich habs aber nicht getestet.
Re: Wie viele Benutzer angemeldet
Hi erstmal grüße an Alle,
die WTSEnumerateSessionsEX ist die lösung (möglicherweise), hier ein beispiel (wurde nur auf Win 7 getestet).
Ciao
jpd
die WTSEnumerateSessionsEX ist die lösung (möglicherweise), hier ein beispiel (wurde nur auf Win 7 getestet).
Code: Alles auswählen
;jpd April 2013
Structure WTS_SESSION_INFO_1
ExecEnvId.l;
State.l
SessionId.l
pSessionName.s
pHostName.s
pUserName.s
pDomainName.s
pFarmName.s
EndStructure
;
Enumeration ;WTS_TYPE_CLASS
#WTSTypeProcessInfoLevel0
#WTSTypeProcessInfoLevel1
#WTSTypeSessionInfoLevel1
EndEnumeration
Prototype WTSEnumerateSessionsEx(hServer, *pLevel, Filter, *ppSessionInfo.WTS_SESSION_INFO_1, *pCount)
Prototype WTSFreeMemoryEx(WTSTypeClass, pMemory, NumberOfEntries);.WTS_TYPE_CLASS
Prototype WTSOpenServer(pServerName)
Prototype WTSCloseServer(hServer)
Global WTSEnumerateSessionsEx.WTSEnumerateSessionsEx
Global WTSFreeMemoryEx.WTSFreeMemoryEx
Global WTSOpenServer.WTSOpenServer
Global WTSCloseServer.WTSCloseServer
Macro lpComputerName(Computername)
Protected lpComputername,lpNullComputername
If ComputerName = "."
lpNullComputername = 0
lpComputername=@lpNullComputername
Else
lpComputername=@Computername
EndIf
EndMacro
Procedure.i wtsapi32_LoadDLL()
Protected.i hDLL
hDLL = OpenLibrary(#PB_Any, "wtsapi32.dll")
If hDLL <> 0
WTSCloseServer = GetFunction(hDLL, "WTSCloseServer")
CompilerIf #PB_Compiler_Unicode
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExW")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExW")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerW")
CompilerElse
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExA")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExA")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerA")
CompilerEndIf
ProcedureReturn hDLL
EndIf
ProcedureReturn #False
EndProcedure
Procedure GetWTSSessions(List ppSessionInfo.WTS_SESSION_INFO_1(), ComputerName.s = ".")
Protected WTSHandle.i
Protected pLevel=1
Protected Filter=0
Protected *SessionInfo
Protected pCount
lpComputerName(Computername)
WTSHandle=WTSOpenServer(lpComputerName)
If WTSHandle
Ret=WTSEnumerateSessionsEx(WTSHandle, @pLevel, Filter,@*SessionInfo,@pCount)
Debug GetLastError_()
If Ret <> 0
For i = 0 To pCount - 1
AddElement(ppSessionInfo())
CopyMemory (*SessionInfo+SizeOf(WTS_SESSION_INFO_1)*i, ppSessionInfo(),SizeOf(WTS_SESSION_INFO_1)*SizeOf(Character))
Next
WTSFreeMemoryEx(#WTSTypeSessionInfoLevel1, *SessionInfo, pCount-1)
EndIf
WTSCloseServer(WTSHandle)
EndIf
EndProcedure
Define.i hDLL
Define NewList ppSessionInfo.WTS_SESSION_INFO_1()
hDLL=wtsapi32_LoadDLL()
If hDLL=0
End
EndIf
GetWTSSessions(ppSessionInfo.WTS_SESSION_INFO_1())
CloseLibrary(hDll)
ForEach ppSessionInfo()
Debug "Session ID: "+ ppSessionInfo()\SessionId
Debug "Session Name: "+ppSessionInfo()\pSessionName
Debug "UserName: "+ ppSessionInfo()\pUserName
Next
jpd
PB 5.10 Windows 7 x64
Re: Wie viele Benutzer angemeldet
Ja, genau das ist es was ich brauche!
Jetzt muss ich bloß noch herausfinden, welche State's ich als Benutzer zählen kann und was zum System gehört. Habe gesehen, dass SessionId "0" immer "Services" ist. Dies ist natürlich kein Benutzer und kann wahrscheinlich beim zählen ausgelassen werden. Ansonsten zähle ich wahrscheinlich alle Einträge mit State 0 (aktiv) und State 4 (angemeldet aber eben nicht aktiv) zusammen. Aber das bekomme ich schon noch genau durch testen heraus.
Danke vielmals!
Jetzt muss ich bloß noch herausfinden, welche State's ich als Benutzer zählen kann und was zum System gehört. Habe gesehen, dass SessionId "0" immer "Services" ist. Dies ist natürlich kein Benutzer und kann wahrscheinlich beim zählen ausgelassen werden. Ansonsten zähle ich wahrscheinlich alle Einträge mit State 0 (aktiv) und State 4 (angemeldet aber eben nicht aktiv) zusammen. Aber das bekomme ich schon noch genau durch testen heraus.
Danke vielmals!
Re: Wie viele Benutzer angemeldet
Hi Purebas,
habe das angepasst so das auch auf XP arbeitet...
habe das angepasst so das auch auf XP arbeitet...
Code: Alles auswählen
;jpd April 2013
Structure WTS_SESSION_INFO
SessionId.l
pWinStationName.s
State.l;.WTS_CONNECTSTATE_CLASS
EndStructure
Structure WTS_SESSION_INFO_1
ExecEnvId.l;
State.l
SessionId.l
pSessionName.s
pHostName.s
pUserName.s
pDomainName.s
pFarmName.s
EndStructure
;
Enumeration ;WTS_CONNECTSTATE_CLASS
#WTSActive
#WTSConnected;
#WTSConnectQuery;
#WTSShadow;
#WTSDisconnected;
#WTSIdle;
#WTSListen;
#WTSReset;
#WTSDown;
#WTSInit;
EndEnumeration
Enumeration ;WTS_TYPE_CLASS
#WTSTypeProcessInfoLevel0
#WTSTypeProcessInfoLevel1
#WTSTypeSessionInfoLevel1
EndEnumeration
Prototype WTSEnumerateSessionsEx(hServer, *pLevel, Filter, *ppSessionInfo.WTS_SESSION_INFO_1, *pCount)
Prototype WTSEnumerateSessions(hServer, Reserved, Version, *ppSessionInfo.WTS_SESSION_INFO, *pCount)
Prototype WTSFreeMemoryEx(WTSTypeClass, pMemory, NumberOfEntries);.WTS_TYPE_CLASS
Prototype WTSFreeMemory(pMemory)
Prototype WTSOpenServer(pServerName)
Prototype WTSCloseServer(hServer)
Global WTSEnumerateSessionsEx.WTSEnumerateSessionsEx
Global WTSEnumerateSessions.WTSEnumerateSessions
Global WTSFreeMemoryEx.WTSFreeMemoryEx
Global WTSFreeMemory.WTSFreeMemory
Global WTSOpenServer.WTSOpenServer
Global WTSCloseServer.WTSCloseServer
Macro lpComputerName(Computername)
Protected lpComputername,lpNullComputername
If ComputerName = "."
lpNullComputername = 0
lpComputername=@lpNullComputername
Else
lpComputername=@Computername
EndIf
EndMacro
Procedure.i wtsapi32_LoadDLL()
Protected.i hDLL
hDLL = OpenLibrary(#PB_Any, "wtsapi32.dll")
If hDLL <> 0
WTSCloseServer = GetFunction(hDLL, "WTSCloseServer")
WTSFreeMemory = GetFunction(hDLL, "WTSFreeMemory")
CompilerIf #PB_Compiler_Unicode
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExW")
WTSEnumerateSessions = GetFunction(hDLL, "WTSEnumerateSessionsW")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExW")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerW")
CompilerElse
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExA")
WTSEnumerateSessions = GetFunction(hDLL, "WTSEnumerateSessionsA")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExA")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerA")
CompilerEndIf
ProcedureReturn hDLL
EndIf
ProcedureReturn #False
EndProcedure
Procedure GetWTSSessions(List ppSessionInfo.WTS_SESSION_INFO_1(), ComputerName.s = ".")
Protected WTSHandle.i
Protected pLevel=1
Protected Filter=0
Protected *SessionInfo
Protected pCount
lpComputerName(Computername)
WTSHandle=WTSOpenServer(lpComputerName)
If WTSHandle
Ret=WTSEnumerateSessionsEx(WTSHandle, @pLevel, Filter,@*SessionInfo,@pCount)
Debug GetLastError_()
If Ret <> 0
For i = 0 To pCount - 1
AddElement(ppSessionInfo())
CopyMemory (*SessionInfo+SizeOf(WTS_SESSION_INFO_1)*i, ppSessionInfo(),SizeOf(WTS_SESSION_INFO_1)*SizeOf(Character))
Next
WTSFreeMemoryEx(#WTSTypeSessionInfoLevel1, *SessionInfo, pCount-1)
EndIf
WTSCloseServer(WTSHandle)
EndIf
EndProcedure
Procedure.s WTS_CONNECTSTATE_CLASS(ValState.l)
Select ValState
Case #WTSActive
ProcedureReturn "A user is logged on To the WinStation."
Case #WTSConnected
ProcedureReturn "The WinStation is connected To the client."
Case #WTSConnectQuery
ProcedureReturn "The WinStation is in the process of connecting To the client."
Case #WTSShadow
ProcedureReturn "The WinStation is shadowing another WinStation."
Case #WTSDisconnected
ProcedureReturn "The WinStation is active but the client is disconnected."
Case #WTSIdle
ProcedureReturn "The WinStation is waiting For a client To connect."
Case #WTSListen
ProcedureReturn "The WinStation is listening For a connection. A listener session waits For requests For new client connections. No user is logged on a listener session. A listener session cannot be reset, shadowed, Or changed To a regular client session."
Case #WTSReset
ProcedureReturn "The WinStation is being reset."
Case #WTSDown
ProcedureReturn "The WinStation is down due To an error."
Case #WTSInit
ProcedureReturn "The WinStation is initializing."
EndSelect
EndProcedure
Procedure IsUserLoggedOn(List ppSessionInfo.WTS_SESSION_INFO(), ComputerName.s = ".")
Protected WTSHandle.i
Protected Version=1
Protected Filter=0
Protected *SessionInfo
Protected pCount
If OSVersion() > #PB_OS_Windows_Vista
lpComputerName(Computername)
WTSHandle=WTSOpenServer(lpComputerName)
Else
WTSHandle=WTSOpenServer(0)
EndIf
If WTSHandle
Ret=WTSEnumerateSessions(WTSHandle, #Null, Version,@*SessionInfo,@pCount)
Debug GetLastError_()
If Ret <> 0
For i = 0 To pCount - 1
AddElement(ppSessionInfo())
CopyMemory (*SessionInfo+SizeOf(WTS_SESSION_INFO)*i, ppSessionInfo(),SizeOf(WTS_SESSION_INFO)*SizeOf(Character))
Next
WTSFreeMemory(*SessionInfo)
EndIf
WTSCloseServer(WTSHandle)
EndIf
EndProcedure
Define.i hDLL
Define NewList ppSessionInfoEx.WTS_SESSION_INFO_1()
Define NewList ppSessionInfo.WTS_SESSION_INFO()
hDLL=wtsapi32_LoadDLL()
If hDLL=0
End
EndIf
If OSVersion() > #PB_OS_Windows_Vista
GetWTSSessions(ppSessionInfoEx.WTS_SESSION_INFO_1())
EndIf
IsUserLoggedOn(ppSessionInfo.WTS_SESSION_INFO())
CloseLibrary(hDll)
Debug "---WTSEnumerateSessionsEx---"
ForEach ppSessionInfoEx()
If ppSessionInfoEx()\State = #WTSActive
Debug "Session ID: "+ ppSessionInfoEx()\SessionId
Debug "Session Name: "+ppSessionInfoEx()\pSessionName
Debug "UserName: "+ ppSessionInfoEx()\pUserName
Debug "Connect Status: "+ WTS_CONNECTSTATE_CLASS(ppSessionInfoEx()\State)
EndIf
Next
Debug "---WTSEnumerateSessions---"
ForEach ppSessionInfo()
If ppSessionInfo()\State = #WTSActive
Debug "WinStationName: "+ ppSessionInfo()\pWinStationName
Debug "Session ID: "+ppSessionInfo()\SessionId
Debug "Connect Status: "+ WTS_CONNECTSTATE_CLASS(ppSessionInfo()\State)
EndIf
Next
PB 5.10 Windows 7 x64
- ts-soft
- Beiträge: 22292
- Registriert: 08.09.2004 00:57
- Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel - Wohnort: Berlin
Re: Wie viele Benutzer angemeldet

Ich hab es auch noch ein bissel angepasst, jetzt klappts auch mit 64-Bit und EnableExplicit.
Code: Alles auswählen
;jpd April 2013
Structure WTS_SESSION_INFO Align #PB_Structure_AlignC
SessionId.l
pWinStationName.s
State.l;.WTS_CONNECTSTATE_CLASS
EndStructure
Structure WTS_SESSION_INFO_1 Align #PB_Structure_AlignC
ExecEnvId.l
State.l
SessionId.l
pSessionName.s
pHostName.s
pUserName.s
pDomainName.s
pFarmName.s
EndStructure
;
Enumeration ;WTS_CONNECTSTATE_CLASS
#WTSActive
#WTSConnected;
#WTSConnectQuery;
#WTSShadow;
#WTSDisconnected;
#WTSIdle;
#WTSListen;
#WTSReset;
#WTSDown;
#WTSInit;
EndEnumeration
Enumeration ;WTS_TYPE_CLASS
#WTSTypeProcessInfoLevel0
#WTSTypeProcessInfoLevel1
#WTSTypeSessionInfoLevel1
EndEnumeration
Prototype WTSEnumerateSessionsEx(hServer, *pLevel, Filter, *ppSessionInfo.WTS_SESSION_INFO_1, *pCount)
Prototype WTSEnumerateSessions(hServer, Reserved, Version, *ppSessionInfo.WTS_SESSION_INFO, *pCount)
Prototype WTSFreeMemoryEx(WTSTypeClass, pMemory, NumberOfEntries);.WTS_TYPE_CLASS
Prototype WTSFreeMemory(pMemory)
Prototype WTSOpenServer(pServerName)
Prototype WTSCloseServer(hServer)
Global WTSEnumerateSessionsEx.WTSEnumerateSessionsEx
Global WTSEnumerateSessions.WTSEnumerateSessions
Global WTSFreeMemoryEx.WTSFreeMemoryEx
Global WTSFreeMemory.WTSFreeMemory
Global WTSOpenServer.WTSOpenServer
Global WTSCloseServer.WTSCloseServer
Macro lpComputerName(Computername)
Protected lpComputername,lpNullComputername
If ComputerName = "."
lpNullComputername = 0
lpComputername=@lpNullComputername
Else
lpComputername=@Computername
EndIf
EndMacro
Procedure.i wtsapi32_LoadDLL()
Protected.i hDLL
hDLL = OpenLibrary(#PB_Any, "wtsapi32.dll")
If hDLL <> 0
WTSCloseServer = GetFunction(hDLL, "WTSCloseServer")
WTSFreeMemory = GetFunction(hDLL, "WTSFreeMemory")
CompilerIf #PB_Compiler_Unicode
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExW")
WTSEnumerateSessions = GetFunction(hDLL, "WTSEnumerateSessionsW")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExW")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerW")
CompilerElse
WTSEnumerateSessionsEx = GetFunction(hDLL, "WTSEnumerateSessionsExA")
WTSEnumerateSessions = GetFunction(hDLL, "WTSEnumerateSessionsA")
WTSFreeMemoryEx = GetFunction(hDLL, "WTSFreeMemoryExA")
WTSOpenServer = GetFunction(hDLL, "WTSOpenServerA")
CompilerEndIf
ProcedureReturn hDLL
EndIf
ProcedureReturn #False
EndProcedure
Procedure GetWTSSessions(List ppSessionInfo.WTS_SESSION_INFO_1(), ComputerName.s = ".")
Protected WTSHandle.i
Protected pLevel=1
Protected Filter=0
Protected *SessionInfo
Protected pCount
Protected Ret, i
lpComputerName(Computername)
WTSHandle=WTSOpenServer(lpComputerName)
If WTSHandle
Ret=WTSEnumerateSessionsEx(WTSHandle, @pLevel, Filter,@*SessionInfo,@pCount)
Debug GetLastError_()
If Ret <> 0
For i = 0 To pCount - 1
AddElement(ppSessionInfo())
CopyMemory (*SessionInfo+SizeOf(WTS_SESSION_INFO_1)*i, ppSessionInfo(),SizeOf(WTS_SESSION_INFO_1)*SizeOf(Character))
Next
WTSFreeMemoryEx(#WTSTypeSessionInfoLevel1, *SessionInfo, pCount-1)
EndIf
WTSCloseServer(WTSHandle)
EndIf
EndProcedure
Procedure.s WTS_CONNECTSTATE_CLASS(ValState.l)
Select ValState
Case #WTSActive
ProcedureReturn "A user is logged on To the WinStation."
Case #WTSConnected
ProcedureReturn "The WinStation is connected To the client."
Case #WTSConnectQuery
ProcedureReturn "The WinStation is in the process of connecting To the client."
Case #WTSShadow
ProcedureReturn "The WinStation is shadowing another WinStation."
Case #WTSDisconnected
ProcedureReturn "The WinStation is active but the client is disconnected."
Case #WTSIdle
ProcedureReturn "The WinStation is waiting For a client To connect."
Case #WTSListen
ProcedureReturn "The WinStation is listening For a connection. A listener session waits For requests For new client connections. No user is logged on a listener session. A listener session cannot be reset, shadowed, Or changed To a regular client session."
Case #WTSReset
ProcedureReturn "The WinStation is being reset."
Case #WTSDown
ProcedureReturn "The WinStation is down due To an error."
Case #WTSInit
ProcedureReturn "The WinStation is initializing."
EndSelect
EndProcedure
Procedure IsUserLoggedOn(List ppSessionInfo.WTS_SESSION_INFO(), ComputerName.s = ".")
Protected WTSHandle.i
Protected Version=1
Protected Filter=0
Protected *SessionInfo
Protected pCount
Protected Ret, i
If OSVersion() > #PB_OS_Windows_Vista
lpComputerName(Computername)
WTSHandle=WTSOpenServer(lpComputerName)
Else
WTSHandle=WTSOpenServer(0)
EndIf
If WTSHandle
Ret=WTSEnumerateSessions(WTSHandle, #Null, Version,@*SessionInfo,@pCount)
Debug GetLastError_()
If Ret <> 0
For i = 0 To pCount - 1
AddElement(ppSessionInfo())
CopyMemory (*SessionInfo+SizeOf(WTS_SESSION_INFO)*i, ppSessionInfo(),SizeOf(WTS_SESSION_INFO)*SizeOf(Character))
Next
WTSFreeMemory(*SessionInfo)
EndIf
WTSCloseServer(WTSHandle)
EndIf
EndProcedure
Define.i hDLL
Define NewList ppSessionInfoEx.WTS_SESSION_INFO_1()
Define NewList ppSessionInfo.WTS_SESSION_INFO()
hDLL=wtsapi32_LoadDLL()
If hDLL=0
End
EndIf
If OSVersion() > #PB_OS_Windows_Vista
GetWTSSessions(ppSessionInfoEx.WTS_SESSION_INFO_1())
EndIf
IsUserLoggedOn(ppSessionInfo.WTS_SESSION_INFO())
CloseLibrary(hDll)
Debug "---WTSEnumerateSessionsEx---"
ForEach ppSessionInfoEx()
If ppSessionInfoEx()\State = #WTSActive
Debug "Session ID: "+ ppSessionInfoEx()\SessionId
Debug "Session Name: "+ppSessionInfoEx()\pSessionName
Debug "UserName: "+ ppSessionInfoEx()\pUserName
Debug "Connect Status: "+ WTS_CONNECTSTATE_CLASS(ppSessionInfoEx()\State)
EndIf
Next
Debug "---WTSEnumerateSessions---"
ForEach ppSessionInfo()
If ppSessionInfo()\State = #WTSActive
Debug "WinStationName: "+ ppSessionInfo()\pWinStationName
Debug "Session ID: "+ppSessionInfo()\SessionId
Debug "Connect Status: "+ WTS_CONNECTSTATE_CLASS(ppSessionInfo()\State)
EndIf
Next
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.

Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
