//
$Id: JwaWtsApi32.pas,v 1.13 2007/09/14 06:48:49 marquardt Exp $
{
$IFNDEF JWA_OMIT_SECTIONS
}
{
$ENDIF JWA_OMIT_SECTIONS
}
{
$IFNDEF JWA_OMIT_SECTIONS
}
{
$ENDIF JWA_OMIT_SECTIONS
}
{
$IFNDEF JWA_IMPLEMENTATIONSECTION
}
//
==============================================================================
//
==============================================================================
//
Specifies the current server
WTS_CURRENT_SERVER = HANDLE(
0
);
{
$EXTERNALSYM WTS_CURRENT_SERVER
}
WTS_CURRENT_SERVER_HANDLE = HANDLE(
0
);
{
$EXTERNALSYM WTS_CURRENT_SERVER_HANDLE
}
WTS_CURRENT_SERVER_NAME =
'
'
;
{
$EXTERNALSYM WTS_CURRENT_SERVER_NAME
}
//
Specifies the current session (SessionId)
WTS_CURRENT_SESSION = DWORD(-
1
);
{
$EXTERNALSYM WTS_CURRENT_SESSION
}
//
Possible pResponse values from WTSSendMessage()
{
$IFNDEF JWA_INCLUDEMODE
}
{
$EXTERNALSYM IDTIMEOUT
}
{
$ENDIF JWA_INCLUDEMODE
}
CLIENTADDRESS_LENGTH =
30
;
WTS_WSD_LOGOFF = $
00000001
;
//
log off all users except
{
$EXTERNALSYM WTS_WSD_LOGOFF
}
//
current user; deletes
//
WinStations (a reboot is
//
required to recreate the
WTS_WSD_SHUTDOWN = $
00000002
;
//
shutdown system
{
$EXTERNALSYM WTS_WSD_SHUTDOWN
}
WTS_WSD_REBOOT = $
00000004
;
//
shutdown and reboot
{
$EXTERNALSYM WTS_WSD_REBOOT
}
WTS_WSD_POWEROFF = $
00000008
;
//
shutdown and power off (on
{
$EXTERNALSYM WTS_WSD_POWEROFF
}
//
machines that support power
WTS_WSD_FASTREBOOT = $
00000010
;
//
reboot without logging users
{
$EXTERNALSYM WTS_WSD_FASTREBOOT
}
//
off or shutting down
//
Added from Server 2008 pre-release SDK
MAX_ELAPSED_TIME_LENGTH =
15
;
MAX_DATE_TIME_LENGTH =
56
;
//
changed from 33 to 32 according to the Windows PSDK v6.1
WINSTATIONNAME_LENGTH =
32
;
//
==============================================================================
//
WTS_CONNECTSTATE_CLASS - Session connect state
//
==============================================================================
_WTS_CONNECTSTATE_CLASS = (
WTSActive,
//
User logged on to WinStation
WTSConnected,
//
WinStation connected to client
WTSConnectQuery,
//
In the process of connecting to client
WTSShadow,
//
Shadowing another WinStation
WTSDisconnected,
//
WinStation logged on without client
WTSIdle,
//
Waiting for client to connect
WTSListen,
//
WinStation is listening for connection
WTSReset,
//
WinStation is being reset
WTSDown,
//
WinStation is down due to error
WTSInit);
//
WinStation in initialization
{
$EXTERNALSYM _WTS_CONNECTSTATE_CLASS
}
WTS_CONNECTSTATE_CLASS = _WTS_CONNECTSTATE_CLASS;
{
$EXTERNALSYM WTS_CONNECTSTATE_CLASS
}
TWtsConnectStateClass = WTS_CONNECTSTATE_CLASS;
//
==============================================================================
//
WTS_SERVER_INFO - returned by WTSEnumerateServers (version 1)
//
==============================================================================
//
WTSEnumerateServers() returns two variables: pServerInfo and Count.
//
The latter is the number of WTS_SERVER_INFO structures contained in
//
the former. In order to read each server, iterate i from 0 to
//
Count-1 and reference the server name as
//
pServerInfo[i].pServerName; for example:
//
for ( i=0; i < Count; i++ ) {
//
_tprintf( TEXT("%s "), pServerInfo[i].pServerName );
//
The memory returned looks like the following. P is a pServerInfo
//
pointer, and D is the string data for that pServerInfo:
//
P1 P2 P3 P4 ... Pn D1 D2 D3 D4 ... Dn
//
This makes it easier to iterate the servers, using code similar to
PWTS_SERVER_INFOW = ^WTS_SERVER_INFOW;
{
$EXTERNALSYM PWTS_SERVER_INFOW
}
_WTS_SERVER_INFOW =
record
pServerName: LPWSTR;
//
server name
{
$EXTERNALSYM _WTS_SERVER_INFOW
}
WTS_SERVER_INFOW = _WTS_SERVER_INFOW;
{
$EXTERNALSYM WTS_SERVER_INFOW
}
TWtsServerInfoW = WTS_SERVER_INFOW;
PWtsServerInfoW = PWTS_SERVER_INFOW;
PWTS_SERVER_INFOA = ^WTS_SERVER_INFOA;
{
$EXTERNALSYM PWTS_SERVER_INFOA
}
_WTS_SERVER_INFOA =
record
pServerName: LPSTR;
//
server name
{
$EXTERNALSYM _WTS_SERVER_INFOA
}
WTS_SERVER_INFOA = _WTS_SERVER_INFOA;
{
$EXTERNALSYM WTS_SERVER_INFOA
}
TWtsServerInfoA = WTS_SERVER_INFOA;
PWtsServerInfoA = PWTS_SERVER_INFOA;
WTS_SERVER_INFO = WTS_SERVER_INFOW;
{
$EXTERNALSYM WTS_SERVER_INFO
}
PWTS_SERVER_INFO = PWTS_SERVER_INFOW;
{
$EXTERNALSYM PWTS_SERVER_INFO
}
TWtsServerInfo = TWtsServerInfoW;
PWtsServerInfo = PWtsServerInfoW;
WTS_SERVER_INFO = WTS_SERVER_INFOA;
{
$EXTERNALSYM WTS_SERVER_INFO
}
PWTS_SERVER_INFO = PWTS_SERVER_INFOA;
{
$EXTERNALSYM PWTS_SERVER_INFO
}
TWtsServerInfo = TWtsServerInfoA;
PWtsServerInfo = PWtsServerInfoA;
//
==============================================================================
//
WTS_SESSION_INFO - returned by WTSEnumerateSessions (version 1)
//
==============================================================================
//
WTSEnumerateSessions() returns data in a similar format to the above
//
WTSEnumerateServers(). It returns two variables: pSessionInfo and
//
Count. The latter is the number of WTS_SESSION_INFO structures
//
contained in the former. Iteration is similar, except that there
//
are three parts to each entry, so it would look like this:
//
for ( i=0; i < Count; i++ ) {
//
_tprintf( TEXT("%-5u %-20s %u\n"),
//
pSessionInfo[i].SessionId,
//
pSessionInfo[i].pWinStationName,
//
pSessionInfo[i].State );
//
The memory returned is also segmented as the above, with all the
//
structures allocated at the start and the string data at the end.
//
We'll use S for the SessionId, P for the pWinStationName pointer
//
and D for the string data, and C for the connect State:
//
S1 P1 C1 S2 P2 C2 S3 P3 C3 S4 P4 C4 ... Sn Pn Cn D1 D2 D3 D4 ... Dn
//
As above, this makes it easier to iterate the sessions.
PWTS_SESSION_INFOW = ^WTS_SESSION_INFOW;
{
$EXTERNALSYM PWTS_SESSION_INFOW
}
_WTS_SESSION_INFOW =
record
SessionId: DWORD;
//
session id
pWinStationName: LPWSTR;
//
name of WinStation this session is connected to
State: WTS_CONNECTSTATE_CLASS;
//
connection state (see enum)
{
$EXTERNALSYM _WTS_SESSION_INFOW
}
WTS_SESSION_INFOW = _WTS_SESSION_INFOW;
{
$EXTERNALSYM WTS_SESSION_INFOW
}
TWtsSessionInfoW = WTS_SESSION_INFOW;
PWtsSessionInfoW = PWTS_SESSION_INFOW;
PWTS_SESSION_INFOA = ^WTS_SESSION_INFOA;
{
$EXTERNALSYM PWTS_SESSION_INFOA
}
_WTS_SESSION_INFOA =
record
SessionId: DWORD;
//
session id
pWinStationName: LPSTR;
//
name of WinStation this session is connected to
State: WTS_CONNECTSTATE_CLASS;
//
connection state (see enum)
{
$EXTERNALSYM _WTS_SESSION_INFOA
}
WTS_SESSION_INFOA = _WTS_SESSION_INFOA;
{
$EXTERNALSYM WTS_SESSION_INFOA
}
TWtsSessionInfoA = WTS_SESSION_INFOA;
PWtsSessionInfoA = PWTS_SESSION_INFOA;
WTS_SESSION_INFO = WTS_SESSION_INFOW;
PWTS_SESSION_INFO = PWTS_SESSION_INFOW;
TWtsSessionInfo = TWtsSessionInfoW;
PWtsSessionInfo = PWtsSessionInfoW;
WTS_SESSION_INFO = WTS_SESSION_INFOA;
PWTS_SESSION_INFO = PWTS_SESSION_INFOA;
TWtsSessionInfo = TWtsSessionInfoA;
PWtsSessionInfo = PWtsSessionInfoA;
//
==============================================================================
//
WTS_PROCESS_INFO - returned by WTSEnumerateProcesses (version 1)
//
==============================================================================
//
WTSEnumerateProcesses() also returns data similar to
//
WTSEnumerateServers(). It returns two variables: pProcessInfo and
//
Count. The latter is the number of WTS_PROCESS_INFO structures
//
contained in the former. Iteration is similar, except that there
//
are four parts to each entry, so it would look like this:
//
for ( i=0; i < Count; i++ ) {
//
GetUserNameFromSid( pProcessInfo[i].pUserSid, UserName,
//
_tprintf( TEXT("%-5u %-20s %-5u %s\n"),
//
pProcessInfo[i].SessionId,
//
pProcessInfo[i].ProcessId,
//
pProcessInfo[i].pProcessName );
//
The memory returned is also segmented as the above, with all the
//
structures allocated at the start and the string data at the end.
//
We'll use S for the SessionId, R for the ProcessId, P for the
//
pProcessName pointer and D for the string data, and U for pUserSid:
//
S1 R1 P1 U1 S2 R2 P2 U2 S3 R3 P3 U3 ... Sn Rn Pn Un D1 D2 D3 ... Dn
//
As above, this makes it easier to iterate the processes.
PWTS_PROCESS_INFOW = ^WTS_PROCESS_INFOW;
{
$EXTERNALSYM PWTS_PROCESS_INFOW
}
_WTS_PROCESS_INFOW =
record
SessionId: DWORD;
//
session id
ProcessId: DWORD;
//
process id
pProcessName: LPWSTR;
//
name of process
pUserSid: PSID;
//
user's SID
{
$EXTERNALSYM _WTS_PROCESS_INFOW
}
WTS_PROCESS_INFOW = _WTS_PROCESS_INFOW;
{
$EXTERNALSYM WTS_PROCESS_INFOW
}
TWtsProcessInfoW = WTS_PROCESS_INFOW;
PWtsProcessInfoW = PWTS_PROCESS_INFOW;
PWTS_PROCESS_INFOA = ^WTS_PROCESS_INFOA;
{
$EXTERNALSYM PWTS_PROCESS_INFOA
}
_WTS_PROCESS_INFOA =
record
SessionId: DWORD;
//
session id
ProcessId: DWORD;
//
process id
pProcessName: LPSTR;
//
name of process
pUserSid: PSID;
//
user's SID
{
$EXTERNALSYM _WTS_PROCESS_INFOA
}
WTS_PROCESS_INFOA = _WTS_PROCESS_INFOA;
{
$EXTERNALSYM WTS_PROCESS_INFOA
}
TWtsProcessInfoA = WTS_PROCESS_INFOA;
PWtsProcessInfoA = PWTS_PROCESS_INFOA;
WTS_PROCESS_INFO = WTS_PROCESS_INFOW;
{
$EXTERNALSYM WTS_PROCESS_INFO
}
PWTS_PROCESS_INFO = PWTS_PROCESS_INFOW;
{
$EXTERNALSYM PWTS_PROCESS_INFO
}
TWtsProcessInfo = TWtsProcessInfoW;
PWtsProcessInfo = PWtsProcessInfoW;
WTS_PROCESS_INFO = WTS_PROCESS_INFOA;
{
$EXTERNALSYM WTS_PROCESS_INFO
}
PWTS_PROCESS_INFO = PWTS_PROCESS_INFOA;
{
$EXTERNALSYM PWTS_PROCESS_INFO
}
TWtsProcessInfo = TWtsProcessInfoA;
PWtsProcessInfo = PWtsProcessInfoA;
//
==============================================================================
//
WTS_INFO_CLASS - WTSQuerySessionInformation
//
(See additional typedefs for more info on structures)
//
==============================================================================
WTS_PROTOCOL_TYPE_CONSOLE =
0
;
//
Console
{
$EXTERNALSYM WTS_PROTOCOL_TYPE_CONSOLE
}
WTS_PROTOCOL_TYPE_ICA =
1
;
//
ICA Protocol
{
$EXTERNALSYM WTS_PROTOCOL_TYPE_ICA
}
WTS_PROTOCOL_TYPE_RDP =
2
;
//
RDP Protocol
{
$EXTERNALSYM WTS_PROTOCOL_TYPE_RDP
}
{
$EXTERNALSYM _WTS_INFO_CLASS
}
WTS_INFO_CLASS = _WTS_INFO_CLASS;
TWtsInfoClass = WTS_INFO_CLASS;
//
==============================================================================
//
WTS Session Information (Unicode)
//
==============================================================================
State : WTS_CONNECTSTATE_CLASS ;
//
connection state (see enum)
SessionId : DWORD;
//
session id
IncomingCompressedBytes : DWORD;
OutgoingCompressedBytes : DWORD;
WinStationName :
array
[
0
..WINSTATIONNAME_LENGTH -
1
]
of
WCHAR;
Domain :
array
[
0
..DOMAIN_LENGTH -
1
]
of
WCHAR;
UserName :
array
[
0
..USERNAME_LENGTH
{
+ 1 - 1
}
]
of
WCHAR;
//
name of WinStation this session is
ConnectTime : LARGE_INTEGER;
DisconnectTime : LARGE_INTEGER;
LastInputTime : LARGE_INTEGER;
LogonTime : LARGE_INTEGER;
CurrentTime : LARGE_INTEGER;
{
$EXTERNALSYM _WTSINFOW
}
{
$EXTERNALSYM WTSINFOW
}
{
$EXTERNALSYM PWTSINFOW
}
//
==============================================================================
//
WTS Session Information (Non-Unicode)
//
==============================================================================
State : WTS_CONNECTSTATE_CLASS ;
//
connection state (see enum)
SessionId : DWORD;
//
session id
IncomingCompressedBytes : DWORD;
OutgoingCompressedBytes : DWORD;
WinStationName :
array
[
0
..WINSTATIONNAME_LENGTH -
1
]
of
CHAR;
Domain :
array
[
0
..DOMAIN_LENGTH -
1
]
of
CHAR;
UserName :
array
[
0
..USERNAME_LENGTH
{
+ 1 - 1
}
]
of
CHAR;
//
name of WinStation this session is
ConnectTime : LARGE_INTEGER;
DisconnectTime : LARGE_INTEGER;
LastInputTime : LARGE_INTEGER;
LogonTime : LARGE_INTEGER;
CurrentTime : LARGE_INTEGER;
{
$EXTERNALSYM _WTSINFOA
}
{
$EXTERNALSYM WTSINFOA
}
{
$EXTERNALSYM PWTSINFOW
}
//
==============================================================================
//
WTS Client Information (Unicode)
//
==============================================================================
ClientName :
array
[
0
..CLIENTNAME_LENGTH
{
+ 1 - 1
}
]
of
WCHAR;
Domain :
array
[
0
..DOMAIN_LENGTH
{
+ 1 - 1
}
]
of
WCHAR;
UserName :
array
[
0
..USERNAME_LENGTH
{
+ 1 - 1
}
]
of
WCHAR;
WorkDirectory :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
WCHAR;
InitialProgram :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
WCHAR;
EncryptionLevel : BYTE;
//
security level of encryption pd
ClientAddressFamily : ULONG;
ClientAddress :
array
[
0
..CLIENTADDRESS_LENGTH
{
+ 1 - 1
}
]
of
USHORT;
ClientDirectory :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
WCHAR;
ClientBuildNumber : ULONG;
ClientHardwareId : ULONG;
//
client software serial number
ClientProductId : USHORT;
//
client software product id
OutBufCountHost : USHORT;
//
number of outbufs on host
OutBufCountClient : USHORT;
//
number of outbufs on client
OutBufLength : USHORT;
//
length of outbufs in bytes
DeviceId :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
WCHAR;
{
$EXTERNALSYM _WTSCLIENTW
}
WTSCLIENTW = _WTSCLIENTW;
{
$EXTERNALSYM WTSCLIENTW
}
PWTSCLIENTW = ^WTSCLIENTW;
{
$EXTERNALSYM PWTSCLIENTW
}
TWtsClientW = WTSCLIENTW;
//
==============================================================================
//
WTS Client Information (Non-Unicode)
//
==============================================================================
ClientName :
array
[
0
..CLIENTNAME_LENGTH
{
+ 1 - 1
}
]
of
CHAR;
Domain :
array
[
0
..DOMAIN_LENGTH
{
+ 1 - 1
}
]
of
CHAR;
UserName :
array
[
0
..USERNAME_LENGTH
{
+ 1 - 1
}
]
of
CHAR;
WorkDirectory :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
CHAR;
InitialProgram :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
CHAR;
EncryptionLevel : BYTE;
//
security level of encryption pd
ClientAddressFamily : ULONG;
ClientAddress :
array
[
0
..CLIENTADDRESS_LENGTH
{
+ 1 - 1
}
]
of
USHORT;
ClientDirectory :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
CHAR;
ClientBuildNumber : ULONG;
ClientHardwareId : ULONG;
//
client software serial number
ClientProductId : USHORT;
//
client software product id
OutBufCountHost : USHORT;
//
number of outbufs on host
OutBufCountClient : USHORT;
//
number of outbufs on client
OutBufLength : USHORT;
//
length of outbufs in bytes
DeviceId :
array
[
0
..MAX_PATH
{
+ 1 - 1
}
]
of
CHAR;
{
$EXTERNALSYM _WTSCLIENTA
}
WTSCLIENTA = _WTSCLIENTA;
{
$EXTERNALSYM WTSCLIENTA
}
PWTSCLIENTA = ^WTSCLIENTA;
{
$EXTERNALSYM PWTSCLIENTA
}
TWtsClientA = WTSCLIENTA;
{
$EXTERNALSYM PWTSINFO
}
{
$EXTERNALSYM WTSCLIENT
}
PWTSCLIENT = PWTSCLIENTW;
{
$EXTERNALSYM PWTSCLIENT
}
{
$EXTERNALSYM PWTSINFO
}
{
$EXTERNALSYM WTSCLIENT
}
PWTSCLIENT = PWTSCLIENTA;
{
$EXTERNALSYM PWTSCLIENT
}
//
==============================================================================
//
WTSQuerySessionInformation - (WTSClientAddress)
//
==============================================================================
PWTS_CLIENT_ADDRESS = ^WTS_CLIENT_ADDRESS;
{
$EXTERNALSYM PWTS_CLIENT_ADDRESS
}
_WTS_CLIENT_ADDRESS =
record
AddressFamily: DWORD;
//
AF_INET, AF_IPX, AF_NETBIOS, AF_UNSPEC
Address:
array
[
0
..
19
]
of
BYTE;
//
client network address
{
$EXTERNALSYM _WTS_CLIENT_ADDRESS
}
WTS_CLIENT_ADDRESS = _WTS_CLIENT_ADDRESS;
{
$EXTERNALSYM WTS_CLIENT_ADDRESS
}
TWtsClientAddress = WTS_CLIENT_ADDRESS;
PWtsClientAddress = PWTS_CLIENT_ADDRESS;
//
==============================================================================
//
WTSQuerySessionInformation - (WTSClientDisplay)
//
==============================================================================
PWTS_CLIENT_DISPLAY = ^WTS_CLIENT_DISPLAY;
{
$EXTERNALSYM PWTS_CLIENT_DISPLAY
}
_WTS_CLIENT_DISPLAY =
record
HorizontalResolution: DWORD;
//
horizontal dimensions, in pixels
VerticalResolution: DWORD;
//
vertical dimensions, in pixels
ColorDepth: DWORD;
//
1=16, 2=256, 4=16M, 8=24M, 16=15M
{
$EXTERNALSYM _WTS_CLIENT_DISPLAY
}
WTS_CLIENT_DISPLAY = _WTS_CLIENT_DISPLAY;
{
$EXTERNALSYM WTS_CLIENT_DISPLAY
}
TWtsClientDisplay = WTS_CLIENT_DISPLAY;
PWtsClientDisplay = PWTS_CLIENT_DISPLAY;
//
==============================================================================
//
WTS_CONFIG_CLASS - WTSQueryUserConfig/WTSSetUserConfig
//
==============================================================================
//
Initial program settings
WTSUserConfigInitialProgram,
//
string returned/expected
WTSUserConfigWorkingDirectory,
//
string returned/expected
WTSUserConfigfInheritInitialProgram,
//
DWORD returned/expected
WTSUserConfigfAllowLogonTerminalServer,
//
DWORD returned/expected
WTSUserConfigTimeoutSettingsConnections,
//
DWORD returned/expected
WTSUserConfigTimeoutSettingsDisconnections,
//
DWORD returned/expected
WTSUserConfigTimeoutSettingsIdle,
//
DWORD returned/expected
//
Client device settings
WTSUserConfigfDeviceClientDrives,
//
DWORD returned/expected
WTSUserConfigfDeviceClientPrinters,
//
DWORD returned/expected
WTSUserConfigfDeviceClientDefaultPrinter,
//
DWORD returned/expected
WTSUserConfigBrokenTimeoutSettings,
//
DWORD returned/expected
WTSUserConfigReconnectSettings,
//
DWORD returned/expected
WTSUserConfigModemCallbackSettings,
//
DWORD returned/expected
WTSUserConfigModemCallbackPhoneNumber,
//
string returned/expected
WTSUserConfigShadowingSettings,
//
DWORD returned/expected
WTSUserConfigTerminalServerProfilePath,
//
string returned/expected
//
Terminal Server home directory
WTSUserConfigTerminalServerHomeDir,
//
string returned/expected
WTSUserConfigTerminalServerHomeDirDrive,
//
string returned/expected
WTSUserConfigfTerminalServerRemoteHomeDir);
//
DWORD 0:LOCAL 1:REMOTE
{
$EXTERNALSYM _WTS_CONFIG_CLASS
}
WTS_CONFIG_CLASS = _WTS_CONFIG_CLASS;
TWtsConfigClass = WTS_CONFIG_CLASS;
//
There we're remove in June 2001 PSDK (pre-release)
PWTS_USER_CONFIG_SET_NWSERVERW = ^WTS_USER_CONFIG_SET_NWSERVERW;
{
$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVERW
}
_WTS_USER_CONFIG_SET_NWSERVERW =
record
pNWDomainAdminName: LPWSTR;
pNWDomainAdminPassword: LPWSTR;
{
$EXTERNALSYM _WTS_USER_CONFIG_SET_NWSERVERW
}
WTS_USER_CONFIG_SET_NWSERVERW = _WTS_USER_CONFIG_SET_NWSERVERW;
{
$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVERW
}
TWtsUserConfigSetNwserverW = WTS_USER_CONFIG_SET_NWSERVERW;
PWtsUserConfigSetNwserverW = PWTS_USER_CONFIG_SET_NWSERVERW;
PWTS_USER_CONFIG_SET_NWSERVERA = ^WTS_USER_CONFIG_SET_NWSERVERA;
{
$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVERA
}
_WTS_USER_CONFIG_SET_NWSERVERA =
record
pNWDomainAdminName: LPSTR;
pNWDomainAdminPassword: LPSTR;
{
$EXTERNALSYM _WTS_USER_CONFIG_SET_NWSERVERA
}
WTS_USER_CONFIG_SET_NWSERVERA = _WTS_USER_CONFIG_SET_NWSERVERA;
{
$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVERA
}
TWtsUserConfigSetNwserverA = WTS_USER_CONFIG_SET_NWSERVERA;
PWtsUserConfigSetNwserverA = PWTS_USER_CONFIG_SET_NWSERVERA;
WTS_USER_CONFIG_SET_NWSERVER = WTS_USER_CONFIG_SET_NWSERVERW;
{
$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVER
}
PWTS_USER_CONFIG_SET_NWSERVER = PWTS_USER_CONFIG_SET_NWSERVERW;
{
$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVER
}
TWtsUserConfigSetNwserver = TWtsUserConfigSetNwserverW;
PWtsUserConfigSetNwserver = PWtsUserConfigSetNwserverW;
WTS_USER_CONFIG_SET_NWSERVER = WTS_USER_CONFIG_SET_NWSERVERA;
{
$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVER
}
PWTS_USER_CONFIG_SET_NWSERVER = PWTS_USER_CONFIG_SET_NWSERVERA;
{
$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVER
}
TWtsUserConfigSetNwserver = TWtsUserConfigSetNwserverA;
PWtsUserConfigSetNwserver = PWtsUserConfigSetNwserverA;
//
==============================================================================
//
WTS_EVENT - Event flags for WTSWaitSystemEvent
//
==============================================================================
WTS_EVENT_NONE = $
00000000
;
//
return no event
{
$EXTERNALSYM WTS_EVENT_NONE
}
WTS_EVENT_CREATE = $
00000001
;
//
new WinStation created
{
$EXTERNALSYM WTS_EVENT_CREATE
}
WTS_EVENT_DELETE = $
00000002
;
//
existing WinStation deleted
{
$EXTERNALSYM WTS_EVENT_DELETE
}
WTS_EVENT_RENAME = $
00000004
;
//
existing WinStation renamed
{
$EXTERNALSYM WTS_EVENT_RENAME
}
WTS_EVENT_CONNECT = $
00000008
;
//
WinStation connect to client
{
$EXTERNALSYM WTS_EVENT_CONNECT
}
WTS_EVENT_DISCONNECT = $
00000010
;
//
WinStation logged on without client
{
$EXTERNALSYM WTS_EVENT_DISCONNECT
}
WTS_EVENT_LOGON = $
00000020
;
//
user logged on to existing WinStation
{
$EXTERNALSYM WTS_EVENT_LOGON
}
WTS_EVENT_LOGOFF = $
00000040
;
//
user logged off from existing WinStation
{
$EXTERNALSYM WTS_EVENT_LOGOFF
}
WTS_EVENT_STATECHANGE = $
00000080
;
//
WinStation state change
{
$EXTERNALSYM WTS_EVENT_STATECHANGE
}
WTS_EVENT_LICENSE = $
00000100
;
//
license state change
{
$EXTERNALSYM WTS_EVENT_LICENSE
}
WTS_EVENT_ALL = $7fffffff;
//
wait for all event types
{
$EXTERNALSYM WTS_EVENT_ALL
}
WTS_EVENT_FLUSH = DWORD($
80000000
);
//
unblock all waiters
{
$EXTERNALSYM WTS_EVENT_FLUSH
}
//
==============================================================================
//
Flags for HotkeyModifiers in WTSStartRemoteControlSession
//
==============================================================================
REMOTECONTROL_KBDSHIFT_HOTKEY = $
1
;
//
Shift key
{
$EXTERNALSYM REMOTECONTROL_KBDSHIFT_HOTKEY
}
REMOTECONTROL_KBDCTRL_HOTKEY = $
2
;
//
Ctrl key
{
$EXTERNALSYM REMOTECONTROL_KBDCTRL_HOTKEY
}
REMOTECONTROL_KBDALT_HOTKEY = $
4
;
//
Alt key
{
$EXTERNALSYM REMOTECONTROL_KBDALT_HOTKEY
}
//
==============================================================================
//
WTS_VIRTUAL_CLASS - WTSVirtualChannelQuery
//
==============================================================================
_WTS_VIRTUAL_CLASS = (WTSVirtualClientData, WTSVirtualFileHandle);
{
$EXTERNALSYM _WTS_VIRTUAL_CLASS
}
WTS_VIRTUAL_CLASS = _WTS_VIRTUAL_CLASS;
{
$EXTERNALSYM WTS_VIRTUAL_CLASS
}
TWtsVirtualClass = WTS_VIRTUAL_CLASS;
//
==============================================================================
//
Windows Terminal Server public APIs
//
==============================================================================
function
WTSStopRemoteControlSession
(LogonId : ULONG): BOOL; stdcall;
{
$EXTERNALSYM WTSStopRemoteControlSession
}
function
WTSStartRemoteControlSessionW
(pTargetServerName : LPWSTR;
HotkeyModifiers : USHORT): BOOL; stdcall;
{
$EXTERNALSYM WTSStartRemoteControlSessionW
}
function
WTSStartRemoteControlSessionA
(pTargetServerName : LPSTR;
HotkeyModifiers : USHORT): BOOL; stdcall;
{
$EXTERNALSYM WTSStartRemoteControlSessionA
}
function
WTSStartRemoteControlSession
(pTargetServerName : LPSTR;
HotkeyModifiers : USHORT): BOOL; stdcall;
{
$EXTERNALSYM WTSStartRemoteControlSession
}
//
------------------------------------------------------------------------------
function
WTSConnectSessionA
(LogonId : ULONG;
bWait : BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSConnectSessionA
}
function
WTSConnectSessionW
(LogonId : ULONG;
bWait : BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSConnectSessionW
}
function
WTSConnectSession
(LogonId : ULONG;
bWait : BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSConnectSession
}
//
------------------------------------------------------------------------------
function
WTSEnumerateServersA
(pDomainName: LPSTR; Reserved, Version: DWORD;
var
ppServerInfo: PWTS_SERVER_INFOA;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateServersA
}
function
WTSEnumerateServersW
(pDomainName: LPWSTR; Reserved, Version: DWORD;
var
ppServerInfo: PWTS_SERVER_INFOW;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateServersW
}
function
WTSEnumerateServers
(pDomainName: LPTSTR; Reserved, Version: DWORD;
var
ppServerInfo: PWTS_SERVER_INFO;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateServers
}
//
------------------------------------------------------------------------------
function
WTSOpenServerA
(pServerName: LPSTR): HANDLE; stdcall;
{
$EXTERNALSYM WTSOpenServerA
}
function
WTSOpenServerW
(pServerName: LPWSTR): HANDLE; stdcall;
{
$EXTERNALSYM WTSOpenServerW
}
function
WTSOpenServer
(pServerName: LPTSTR): HANDLE; stdcall;
{
$EXTERNALSYM WTSOpenServer
}
//
------------------------------------------------------------------------------
procedure
WTSCloseServer
(hServer: HANDLE); stdcall;
{
$EXTERNALSYM WTSCloseServer
}
//
------------------------------------------------------------------------------
function
WTSEnumerateSessionsA
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppSessionInfo: PWTS_SESSION_INFOA;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateSessionsA
}
function
WTSEnumerateSessionsW
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppSessionInfo: PWTS_SESSION_INFOW;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateSessionsW
}
function
WTSEnumerateSessions
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppSessionInfo: PWTS_SESSION_INFO;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateSessions
}
//
------------------------------------------------------------------------------
function
WTSEnumerateProcessesA
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppProcessInfo: PWTS_PROCESS_INFOA;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateProcessesA
}
function
WTSEnumerateProcessesW
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppProcessInfo: PWTS_PROCESS_INFOW;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateProcessesW
}
function
WTSEnumerateProcesses
(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
var
ppProcessInfo: PWTS_PROCESS_INFO;
var
pCount: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSEnumerateProcesses
}
//
------------------------------------------------------------------------------
function
WTSTerminateProcess
(hServer: HANDLE; ProcessId, ExitCode: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSTerminateProcess
}
//
------------------------------------------------------------------------------
function
WTSQuerySessionInformationA
(hServer: HANDLE; SessionId: DWORD;
WTSInfoClass: WTS_INFO_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQuerySessionInformationA
}
function
WTSQuerySessionInformationW
(hServer: HANDLE; SessionId: DWORD;
WTSInfoClass: WTS_INFO_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQuerySessionInformationW
}
function
WTSQuerySessionInformation
(hServer: HANDLE; SessionId: DWORD;
WTSInfoClass: WTS_INFO_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQuerySessionInformation
}
//
------------------------------------------------------------------------------
function
WTSQueryUserConfigA
(pServerName, pUserName: LPSTR; WTSConfigClass: WTS_CONFIG_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQueryUserConfigA
}
function
WTSQueryUserConfigW
(pServerName, pUserName: LPWSTR; WTSConfigClass: WTS_CONFIG_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQueryUserConfigW
}
function
WTSQueryUserConfig
(pServerName, pUserName: LPTSTR; WTSConfigClass: WTS_CONFIG_CLASS;
var
ppBuffer: Pointer;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSQueryUserConfig
}
//
------------------------------------------------------------------------------
function
WTSSetUserConfigA
(pServerName, pUserName: LPSTR; WTSConfigClass: WTS_CONFIG_CLASS;
pBuffer: LPSTR; DataLength: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSSetUserConfigA
}
function
WTSSetUserConfigW
(pServerName, pUserName: LPWSTR; WTSConfigClass: WTS_CONFIG_CLASS;
pBuffer: LPWSTR; DataLength: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSSetUserConfigW
}
function
WTSSetUserConfig
(pServerName, pUserName: LPTSTR; WTSConfigClass: WTS_CONFIG_CLASS;
pBuffer: LPTSTR; DataLength: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSSetUserConfig
}
//
------------------------------------------------------------------------------
function
WTSSendMessageA
(hServer: HANDLE; SessionId: DWORD; pTitle: LPSTR;
TitleLength: DWORD; pMessage: LPSTR; MessageLength: DWORD; Style: DWORD;
Timeout: DWORD;
var
pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSSendMessageA
}
function
WTSSendMessageW
(hServer: HANDLE; SessionId: DWORD; pTitle: LPWSTR;
TitleLength: DWORD; pMessage: LPWSTR; MessageLength: DWORD; Style: DWORD;
Timeout: DWORD;
var
pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSSendMessageW
}
function
WTSSendMessage
(hServer: HANDLE; SessionId: DWORD; pTitle: LPTSTR;
TitleLength: DWORD; pMessage: LPTSTR; MessageLength: DWORD; Style: DWORD;
Timeout: DWORD;
var
pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSSendMessage
}
//
------------------------------------------------------------------------------
function
WTSDisconnectSession
(hServer: HANDLE; SessionId: DWORD; bWait: BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSDisconnectSession
}
//
------------------------------------------------------------------------------
function
WTSLogoffSession
(hServer: HANDLE; SessionId: DWORD; bWait: BOOL): BOOL; stdcall;
{
$EXTERNALSYM WTSLogoffSession
}
//
------------------------------------------------------------------------------
function
WTSShutdownSystem
(hServer: HANDLE; ShutdownFlag: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSShutdownSystem
}
//
------------------------------------------------------------------------------
function
WTSWaitSystemEvent
(hServer: HANDLE; EventMask: DWORD;
var
pEventFlags: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSWaitSystemEvent
}
//
------------------------------------------------------------------------------
function
WTSVirtualChannelOpen
(hServer: HANDLE; SessionId: DWORD;
pVirtualName: LPSTR): HANDLE; stdcall;
{
$EXTERNALSYM WTSVirtualChannelOpen
}
WTS_CHANNEL_OPTION_DYNAMIC = $
00000001
;
//
dynamic channel
{
$EXTERNALSYM WTS_CHANNEL_OPTION_DYNAMIC
}
//
priorities
WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW = $
00000000
;
{
$EXTERNALSYM WTS_CHANNEL_OPTION_DYNAMIC_PRI_LOW
}
WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED = $
00000002
;
{
$EXTERNALSYM WTS_CHANNEL_OPTION_DYNAMIC_PRI_MED
}
WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH = $
00000004
;
{
$EXTERNALSYM WTS_CHANNEL_OPTION_DYNAMIC_PRI_HIGH
}
WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL = $
00000006
;
{
$EXTERNALSYM WTS_CHANNEL_OPTION_DYNAMIC_PRI_REAL
}
function
WTSVirtualChannelOpenEx
(SessionId : DWORD;
flags : DWORD) : HANDLE; stdcall;
{
$EXTERNALSYM WTSVirtualChannelOpenEx
}
function
WTSVirtualChannelClose
(hChannelHandle: HANDLE): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelClose
}
function
WTSVirtualChannelRead
(hChannelHandle: HANDLE; TimeOut: ULONG;
Buffer: PAnsiChar; BufferSize: ULONG;
var
pBytesRead: ULONG): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelRead
}
function
WTSVirtualChannelWrite
(hChannelHandle: HANDLE; Buffer: PAnsiChar;
Length: ULONG;
var
pBytesWritten: ULONG): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelWrite
}
function
WTSVirtualChannelPurgeInput
(hChannelHandle: HANDLE): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelPurgeInput
}
function
WTSVirtualChannelPurgeOutput
(hChannelHandle: HANDLE): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelPurgeOutput
}
function
WTSVirtualChannelQuery
(hChannelHandle: HANDLE; VirtualClass: WTS_VIRTUAL_CLASS;
ppBuffer: PVOID;
var
pBytesReturned: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSVirtualChannelQuery
}
//
------------------------------------------------------------------------------
procedure
WTSFreeMemory
(pMemory: PVOID); stdcall;
{
$EXTERNALSYM WTSFreeMemory
}
//
Flags for Console Notification
NOTIFY_FOR_ALL_SESSIONS =
1
;
{
$EXTERNALSYM NOTIFY_FOR_ALL_SESSIONS
}
NOTIFY_FOR_THIS_SESSION =
0
;
{
$EXTERNALSYM NOTIFY_FOR_THIS_SESSION
}
function
WTSRegisterSessionNotification
(hWnd: HWND; dwFlags: DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSRegisterSessionNotification
}
function
WTSUnRegisterSessionNotification
(hWnd: HWND): BOOL; stdcall;
{
$EXTERNALSYM WTSUnRegisterSessionNotification
}
function
WTSRegisterSessionNotificationEx
(hServer : Handle;
dwFlags : DWORD): BOOL; stdcall;
{
$EXTERNALSYM WTSRegisterSessionNotificationEx
}
function
WTSUnRegisterSessionNotificationEx
(hServer : Handle;
hWnd : HWND): BOOL; stdcall;
{
$EXTERNALSYM WTSUnRegisterSessionNotificationEx
}
function
WTSQueryUserToken
(SessionId: ULONG;
var
phToken: HANDLE): BOOL; stdcall;
{
$EXTERNALSYM WTSQueryUserToken
}
{
$ENDIF JWA_IMPLEMENTATIONSECTION
}
{
$IFNDEF JWA_OMIT_SECTIONS
}
{
$ENDIF JWA_OMIT_SECTIONS
}
{
$IFNDEF JWA_INTERFACESECTION
}
{
$IFNDEF JWA_INCLUDEMODE
}
wtsapi =
'
wtsapi32.dll
'
;
{
$ENDIF JWA_INCLUDEMODE
}
_WTSStopRemoteControlSession: Pointer;
function
WTSStopRemoteControlSession
;
GetProcedureAddress(_WTSStopRemoteControlSession, wtsapi,
'
WTSStopRemoteControlSession
'
);