Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WTSQuerySessionInformation 1

Status
Not open for further replies.

Kvazar

Programmer
Aug 23, 2011
1
SE
Anyone got a working code for using WTSQuerySessionInformation.
I need to get the WTSClientName for computers connected to my application with Terminalserver.

Regards Dan
 
Hi!

In the Global MAP ::

Code:
  MODULE('WTSAPI32.DLL')
     WTSFreeMemory(ULONG),PASCAL
     WTSQuerySessionInformation(ULONG,ULONG,ULONG,*ULONG,*ULONG),ULONG,PASCAL,RAW,NAME('WTSQuerySessionInformationA')
  END

In the procedure ::

Code:
MemoryAddr           ULONG
StringRef            &CSTRING

WTSCurrServer        LONG(0h)
WTSCurrSession       LONG(-1h)
WTSClientAddress     LONG(14)
WTSClientName        LONG(10)


! Get client computer name
  lcl:Result = WTSQuerySessionInformation(WTS_Current_Server_Handle,WTS_Current_Session,WTSClientName,MemoryAddr,lcl:Length)
  IF lcl:Result
     StringRef &= (MemoryAddr)
     glo:ClientName = StringRef
  END
  WTSFreeMemory(MemoryAddr)

You may need to create a LIB using LibMaker from WTSAPI32.dll of the 2 API functions and link it to the project.

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top