How to read all logged in users

I’m writing a service to read all kind of information from our server into a CubeSQL.

Works pretty nicely, except for one thing. qwinsta can not get read via a service console app, MBS doesn’t have anything etc. and I don’t find any solution for quite a simple problem:

I want to read all users, who are currently logged into to our terminal server …

I hope anyone has an idea. Thank you in advance!


The reference to Qwinsta and terminal server would suggest Windows.

The code in the 3rd post of c++ - How to get the active user when multiple users are logged on in Windows? - Stack Overflow should provide some insight.

The declares should be relatively straightforward, see http://blog./2017/01/22/windows-to-xojo-data-type-conversion/ for more information on that.

Windows indeed! Seems that I was a bit blind though. qwinsta is working on the terminal server … It isn’t working in Xojo on my Surface Windows10 develop. machine …

Dim sh as new Shell
Dim result as string
Dim results(-1) as string
Dim session as String
dim user as String
dim status as string

sh.mode = 0
sh.TimeOut = -1

while sh.IsRunning


result = sh.Result
results = split(result, endofline)

for i as integer = 1 to ubound(results)
	user = trim(mid(results(i),20,21))
	if user <> "" then
		session  = trim(left(results(i),19))
		status =  trim(mid(results(i),49,7))
		databaseTransferValues("LOGINS", session , user, status, "-")
	end if
next i