Obtains the session # that is associated with a process id value in a terminal server environment.
wtsProcIdToSessId(pid)
(i) pid: This is an integer value that represents a process identifier value.
(i) Returns a session identifier.
This function is used to obtain a session identifier that is associated with a process id for a process running in a terminal services environment.
If this functon returns a session identifier value of zero then that means that the process is running on the system console session.
If this function is called on a WinNT v4.0 Workstation/Server system that has had the WTS*() API function libraries copied over to it from a WinNT v4.0 Terminal Server Edition system, then error 907 will be raised. This KERNEL32.DLL library on those systems does not export the Win32 API function that is required for this extender function to work properly.
;Load 32-bit or 64-bit extender AddExtender( "WWWTS44I.DLL" , 0, "WWWTS64I.DLL" )
Title01 = 'Test wtsProcIdToSessId()' ; Get our own PID value for the process running this script... TempPID = DllCall('KERNEL32.DLL',long:'GetCurrentProcessId') ErrorMode(@OFF) Result = wtsProcIdToSessId(TempPID) RC = LastError() ErrorMode(@CANCEL) TempMsg = StrCat('wtsProcIdToSessId(',TempPID,') RC = ',RC,@CRLF) TempMsg = StrCat(TempMsg,@CRLF,'Session # = ',Result) Message(Title01,TempMsg) Exit