Hi All, Windows ChromeBook Edition (W11-22H2). I have been doing a lot of head scratching here. I have a project were I need to use BOOL WTSEnumerateSessionsA( [in] HANDLE hServer, # WTS_CURRENT_SERVER_HANDLE to use the RD Session Host server that hosts your application. [in] DWORD Reserved, [in] DWORD Version, [out] PWTS_SESSION_INFOA *ppSessionInfo, [out] DWORD *pCount ); to dig out a pointer (*ppSessionInfo) to a C++ OOP data structure, which is repeated pCount times. (No problem coding the above.) The data structure is C++ typedef struct _WTS_SESSION_INFOA { DWORD SessionId; # 4 bytes LPSTR pWinStationName; # 4 or 8 or 12 bytes WTS_CONNECTSTATE_CLASS State; # 4 or 8 bytes maybe } WTS_SESSION_INFOA, *PWTS_SESSION_INFOA; "_WTS_SESSION_INFOA" is 12 bytes in x86 and 24 bytes in x64: int nSize1 = sizeof WTS_SESSION_INFOA; // 12 in x86, 24 in x64 What I need to do is shown in C++ WTSEnumerateSessionsA(WTS_CURRENT_SERVER, 0, 1, &pwsi, &dwCount) for (DWORD i = 0; i < dwCount; i++) { if (pwsi[i].State == WTSActive) { dwSession = pwsi[i].SessionId; break; } } Basically, I need to walk though the C++ structure looking for State == WTSActive (0), read the value of SessionId, exit the loop, and return the value of SessionId. How in the world do I use NativeCall to read "_WTS_SESSION_INFOA"'s structure? I will only be operating in 64 bit, so I take it I have to create a Buf of 24 bytes. Then take the buffer apart using little endian. And the [i] in the C++ code will be me incrementing *pCount by 24 bytes each successive read. Is there an easier way to do this? Many thanks, -T I have to do the above becasue the "SessionID" is reported incorrectly by M$'s other API's if you are running your program from the Task Scheduler Oh and I almost forgot: AAAAA HHHHH !!!!! -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computers are like air conditioners. They malfunction when you open windows ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Thread Next