Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than wtsapi32, prefix the name with the module name and a period.
WTSEnumerateProcesses (wtsapi32)
.
C# Signature:
[DllImport("wtsapi32.dll", SetLastError=true)]
static extern bool WTSEnumerateProcesses(
IntPtr serverHandle, // Handle to a terminal server.
Int32 reserved, // must be 0
Int32 version, // must be 1
ref IntPtr ppProcessInfo, // pointer to array of WTS_PROCESS_INFO
ref Int32 pCount // pointer to number of processes
ref Int32 pCount); // pointer to number of processes
);
VB Signature:
Private Declare Function WTSEnumerateProcesses Lib "wtsapi32.dll" ( _
ByVal hServer As Int32, _
ByVal Reserved As Int32, _
ByVal Version As Int32, _
ByRef ppProcessInfo As IntPtr, _
ByRef pCount As Int32
) As Int32
//VB sample code
Dim strucProcessInfo As WTS_PROCESS_INFO
Dim ptrProcessInfo As IntPtr
Dim lngPtrPos As Long
Dim intReturn As Integer
Dim intCount As Integer
Dim intProcessCount As Integer
Dim strProcessName As String
intReturn = WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, ptrProcessInfo, intProcessCount)
If intReturn > 0 Then
'Get the length in bytes of each structure...
lngPtrPos = ptrProcessInfo.ToInt32()
For intCount = 0 To intProcessCount - 1
strucProcessInfo = Marshal.PtrToStructure(New IntPtr(lngPtrPos), strucProcessInfo.GetType)
'ProcessName is merely a pointer to the string - convert it to the full string...
strProcessName = Marshal.PtrToStringAnsi(New IntPtr(strucProcessInfo.ProcessName))
'Now move on the pointer to the next member of the array...
lngPtrPos = lngPtrPos + Len(strucProcessInfo)
Next
End If
Call WTSFreeMemory(ptrProcessInfo)
The WTSEnumerateProcesses function retrieves information about the active processes on a specified terminal server.
5/4/2019 8:24:27 AM - -78.175.55.204
The WTS_PROCESS_INFO structure contains information about a process running on a terminal server.
4/22/2013 6:19:43 PM - -61.144.54.43
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).