How to get the 'WTSSessionID' out of the WTSQuerySessionInformation function??

I need to get the 'SessionID' from a Terminal Server Session.
I've already found a Progress example how to use the 'WTSQuerySessionInformation' to get the username (= WTSInfoClass = 5 => pointer to a null-terminating string).

To get the SessionId I need to call the same function but with the WTSInfoClass = 4 (= pointer to a ULONG variabele)
How can I do this??? I've changed the parameter from 5 to 4 but I don't get a result!!

I also want to use the same function but with the WTSInfoClass = 23 (= WTSClientInfo => pointer to a WTSCLIENT structure)
Can I do this from Progress and How???