jwawtsapi32.pas 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  1. {******************************************************************************}
  2. { }
  3. { Terminal Services API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: wtsapi32.h, released June 2000. The original Pascal }
  9. { code is: WtsApi32.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaWtsApi32;
  43. {$I jediapilib.inc}
  44. interface
  45. uses
  46. JwaWinNT, JwaWinType;
  47. // Windows Terminal Server public APIs
  48. //
  49. // Copyright 1995-1999, Citrix Systems Inc.
  50. // Copyright (c) 1997-1999 Microsoft Corporation
  51. //==============================================================================
  52. // Defines
  53. //==============================================================================
  54. //
  55. // Specifies the current server
  56. //
  57. const
  58. WTS_CURRENT_SERVER = HANDLE(0);
  59. {$EXTERNALSYM WTS_CURRENT_SERVER}
  60. WTS_CURRENT_SERVER_HANDLE = HANDLE(0);
  61. {$EXTERNALSYM WTS_CURRENT_SERVER_HANDLE}
  62. WTS_CURRENT_SERVER_NAME = '';
  63. {$EXTERNALSYM WTS_CURRENT_SERVER_NAME}
  64. //
  65. // Specifies the current session (SessionId)
  66. //
  67. WTS_CURRENT_SESSION = DWORD(-1);
  68. {$EXTERNALSYM WTS_CURRENT_SESSION}
  69. //
  70. // Possible pResponse values from WTSSendMessage()
  71. //
  72. IDTIMEOUT = 32000;
  73. {$EXTERNALSYM IDTIMEOUT}
  74. IDASYNC = 32001;
  75. {$EXTERNALSYM IDASYNC}
  76. //
  77. // Shutdown flags
  78. //
  79. WTS_WSD_LOGOFF = $00000001; // log off all users except
  80. {$EXTERNALSYM WTS_WSD_LOGOFF} // current user; deletes
  81. // WinStations (a reboot is
  82. // required to recreate the
  83. // WinStations)
  84. WTS_WSD_SHUTDOWN = $00000002; // shutdown system
  85. {$EXTERNALSYM WTS_WSD_SHUTDOWN}
  86. WTS_WSD_REBOOT = $00000004; // shutdown and reboot
  87. {$EXTERNALSYM WTS_WSD_REBOOT}
  88. WTS_WSD_POWEROFF = $00000008; // shutdown and power off (on
  89. {$EXTERNALSYM WTS_WSD_POWEROFF}
  90. // machines that support power
  91. // off through software)
  92. WTS_WSD_FASTREBOOT = $00000010; // reboot without logging users
  93. {$EXTERNALSYM WTS_WSD_FASTREBOOT} // off or shutting down
  94. //==============================================================================
  95. // WTS_CONNECTSTATE_CLASS - Session connect state
  96. //==============================================================================
  97. type
  98. _WTS_CONNECTSTATE_CLASS = (
  99. WTSActive, // User logged on to WinStation
  100. WTSConnected, // WinStation connected to client
  101. WTSConnectQuery, // In the process of connecting to client
  102. WTSShadow, // Shadowing another WinStation
  103. WTSDisconnected, // WinStation logged on without client
  104. WTSIdle, // Waiting for client to connect
  105. WTSListen, // WinStation is listening for connection
  106. WTSReset, // WinStation is being reset
  107. WTSDown, // WinStation is down due to error
  108. WTSInit); // WinStation in initialization
  109. {$EXTERNALSYM _WTS_CONNECTSTATE_CLASS}
  110. WTS_CONNECTSTATE_CLASS = _WTS_CONNECTSTATE_CLASS;
  111. {$EXTERNALSYM WTS_CONNECTSTATE_CLASS}
  112. TWtsConnectStateClass = WTS_CONNECTSTATE_CLASS;
  113. //==============================================================================
  114. // WTS_SERVER_INFO - returned by WTSEnumerateServers (version 1)
  115. //==============================================================================
  116. //
  117. // WTSEnumerateServers() returns two variables: pServerInfo and Count.
  118. // The latter is the number of WTS_SERVER_INFO structures contained in
  119. // the former. In order to read each server, iterate i from 0 to
  120. // Count-1 and reference the server name as
  121. // pServerInfo[i].pServerName; for example:
  122. //
  123. // for ( i=0; i < Count; i++ ) {
  124. // _tprintf( TEXT("%s "), pServerInfo[i].pServerName );
  125. // }
  126. //
  127. // The memory returned looks like the following. P is a pServerInfo
  128. // pointer, and D is the string data for that pServerInfo:
  129. //
  130. // P1 P2 P3 P4 ... Pn D1 D2 D3 D4 ... Dn
  131. //
  132. // This makes it easier to iterate the servers, using code similar to
  133. // the above.
  134. //
  135. type
  136. PWTS_SERVER_INFOW = ^WTS_SERVER_INFOW;
  137. {$EXTERNALSYM PWTS_SERVER_INFOW}
  138. _WTS_SERVER_INFOW = record
  139. pServerName: LPWSTR; // server name
  140. end;
  141. {$EXTERNALSYM _WTS_SERVER_INFOW}
  142. WTS_SERVER_INFOW = _WTS_SERVER_INFOW;
  143. {$EXTERNALSYM WTS_SERVER_INFOW}
  144. TWtsServerInfoW = WTS_SERVER_INFOW;
  145. PWtsServerInfoW = PWTS_SERVER_INFOW;
  146. PWTS_SERVER_INFOA = ^WTS_SERVER_INFOA;
  147. {$EXTERNALSYM PWTS_SERVER_INFOA}
  148. _WTS_SERVER_INFOA = record
  149. pServerName: LPSTR; // server name
  150. end;
  151. {$EXTERNALSYM _WTS_SERVER_INFOA}
  152. WTS_SERVER_INFOA = _WTS_SERVER_INFOA;
  153. {$EXTERNALSYM WTS_SERVER_INFOA}
  154. TWtsServerInfoA = WTS_SERVER_INFOA;
  155. PWtsServerInfoA = PWTS_SERVER_INFOA;
  156. {$IFDEF UNICODE}
  157. WTS_SERVER_INFO = WTS_SERVER_INFOW;
  158. {$EXTERNALSYM WTS_SERVER_INFO}
  159. PWTS_SERVER_INFO = PWTS_SERVER_INFOW;
  160. {$EXTERNALSYM PWTS_SERVER_INFO}
  161. TWtsServerInfo = TWtsServerInfoW;
  162. PWtsServerInfo = PWtsServerInfoW;
  163. {$ELSE}
  164. WTS_SERVER_INFO = WTS_SERVER_INFOA;
  165. {$EXTERNALSYM WTS_SERVER_INFO}
  166. PWTS_SERVER_INFO = PWTS_SERVER_INFOA;
  167. {$EXTERNALSYM PWTS_SERVER_INFO}
  168. TWtsServerInfo = TWtsServerInfoA;
  169. PWtsServerInfo = PWtsServerInfoA;
  170. {$ENDIF UNICODE}
  171. //==============================================================================
  172. // WTS_SESSION_INFO - returned by WTSEnumerateSessions (version 1)
  173. //==============================================================================
  174. //
  175. // WTSEnumerateSessions() returns data in a similar format to the above
  176. // WTSEnumerateServers(). It returns two variables: pSessionInfo and
  177. // Count. The latter is the number of WTS_SESSION_INFO structures
  178. // contained in the former. Iteration is similar, except that there
  179. // are three parts to each entry, so it would look like this:
  180. //
  181. // for ( i=0; i < Count; i++ ) {
  182. // _tprintf( TEXT("%-5u %-20s %u\n"),
  183. // pSessionInfo[i].SessionId,
  184. // pSessionInfo[i].pWinStationName,
  185. // pSessionInfo[i].State );
  186. // }
  187. //
  188. // The memory returned is also segmented as the above, with all the
  189. // structures allocated at the start and the string data at the end.
  190. // We'll use S for the SessionId, P for the pWinStationName pointer
  191. // and D for the string data, and C for the connect State:
  192. //
  193. // S1 P1 C1 S2 P2 C2 S3 P3 C3 S4 P4 C4 ... Sn Pn Cn D1 D2 D3 D4 ... Dn
  194. //
  195. // As above, this makes it easier to iterate the sessions.
  196. //
  197. type
  198. PWTS_SESSION_INFOW = ^WTS_SESSION_INFOW;
  199. {$EXTERNALSYM PWTS_SESSION_INFOW}
  200. _WTS_SESSION_INFOW = record
  201. SessionId: DWORD; // session id
  202. pWinStationName: LPWSTR; // name of WinStation this session is connected to
  203. State: WTS_CONNECTSTATE_CLASS; // connection state (see enum)
  204. end;
  205. {$EXTERNALSYM _WTS_SESSION_INFOW}
  206. WTS_SESSION_INFOW = _WTS_SESSION_INFOW;
  207. {$EXTERNALSYM WTS_SESSION_INFOW}
  208. TWtsSessionInfoW = WTS_SESSION_INFOW;
  209. PWtsSessionInfoW = PWTS_SESSION_INFOW;
  210. PWTS_SESSION_INFOA = ^WTS_SESSION_INFOA;
  211. {$EXTERNALSYM PWTS_SESSION_INFOA}
  212. _WTS_SESSION_INFOA = record
  213. SessionId: DWORD; // session id
  214. pWinStationName: LPSTR; // name of WinStation this session is connected to
  215. State: WTS_CONNECTSTATE_CLASS; // connection state (see enum)
  216. end;
  217. {$EXTERNALSYM _WTS_SESSION_INFOA}
  218. WTS_SESSION_INFOA = _WTS_SESSION_INFOA;
  219. {$EXTERNALSYM WTS_SESSION_INFOA}
  220. TWtsSessionInfoA = WTS_SESSION_INFOA;
  221. PWtsSessionInfoA = PWTS_SESSION_INFOA;
  222. {$IFDEF UNICODE}
  223. WTS_SESSION_INFO = WTS_SESSION_INFOW;
  224. PWTS_SESSION_INFO = PWTS_SESSION_INFOW;
  225. TWtsSessionInfo = TWtsSessionInfoW;
  226. PWtsSessionInfo = PWtsSessionInfoW;
  227. {$ELSE}
  228. WTS_SESSION_INFO = WTS_SESSION_INFOA;
  229. PWTS_SESSION_INFO = PWTS_SESSION_INFOA;
  230. TWtsSessionInfo = TWtsSessionInfoA;
  231. PWtsSessionInfo = PWtsSessionInfoA;
  232. {$ENDIF UNICODE}
  233. //==============================================================================
  234. // WTS_PROCESS_INFO - returned by WTSEnumerateProcesses (version 1)
  235. //==============================================================================
  236. //
  237. // WTSEnumerateProcesses() also returns data similar to
  238. // WTSEnumerateServers(). It returns two variables: pProcessInfo and
  239. // Count. The latter is the number of WTS_PROCESS_INFO structures
  240. // contained in the former. Iteration is similar, except that there
  241. // are four parts to each entry, so it would look like this:
  242. //
  243. // for ( i=0; i < Count; i++ ) {
  244. // GetUserNameFromSid( pProcessInfo[i].pUserSid, UserName,
  245. // sizeof(UserName) );
  246. // _tprintf( TEXT("%-5u %-20s %-5u %s\n"),
  247. // pProcessInfo[i].SessionId,
  248. // UserName,
  249. // pProcessInfo[i].ProcessId,
  250. // pProcessInfo[i].pProcessName );
  251. // }
  252. //
  253. // The memory returned is also segmented as the above, with all the
  254. // structures allocated at the start and the string data at the end.
  255. // We'll use S for the SessionId, R for the ProcessId, P for the
  256. // pProcessName pointer and D for the string data, and U for pUserSid:
  257. //
  258. // S1 R1 P1 U1 S2 R2 P2 U2 S3 R3 P3 U3 ... Sn Rn Pn Un D1 D2 D3 ... Dn
  259. //
  260. // As above, this makes it easier to iterate the processes.
  261. //
  262. type
  263. PWTS_PROCESS_INFOW = ^WTS_PROCESS_INFOW;
  264. {$EXTERNALSYM PWTS_PROCESS_INFOW}
  265. _WTS_PROCESS_INFOW = record
  266. SessionId: DWORD; // session id
  267. ProcessId: DWORD; // process id
  268. pProcessName: LPWSTR; // name of process
  269. pUserSid: PSID; // user's SID
  270. end;
  271. {$EXTERNALSYM _WTS_PROCESS_INFOW}
  272. WTS_PROCESS_INFOW = _WTS_PROCESS_INFOW;
  273. {$EXTERNALSYM WTS_PROCESS_INFOW}
  274. TWtsProcessInfoW = WTS_PROCESS_INFOW;
  275. PWtsProcessInfoW = PWTS_PROCESS_INFOW;
  276. PWTS_PROCESS_INFOA = ^WTS_PROCESS_INFOA;
  277. {$EXTERNALSYM PWTS_PROCESS_INFOA}
  278. _WTS_PROCESS_INFOA = record
  279. SessionId: DWORD; // session id
  280. ProcessId: DWORD; // process id
  281. pProcessName: LPSTR; // name of process
  282. pUserSid: PSID; // user's SID
  283. end;
  284. {$EXTERNALSYM _WTS_PROCESS_INFOA}
  285. WTS_PROCESS_INFOA = _WTS_PROCESS_INFOA;
  286. {$EXTERNALSYM WTS_PROCESS_INFOA}
  287. TWtsProcessInfoA = WTS_PROCESS_INFOA;
  288. PWtsProcessInfoA = PWTS_PROCESS_INFOA;
  289. {$IFDEF UNICODE}
  290. WTS_PROCESS_INFO = WTS_PROCESS_INFOW;
  291. {$EXTERNALSYM WTS_PROCESS_INFO}
  292. PWTS_PROCESS_INFO = PWTS_PROCESS_INFOW;
  293. {$EXTERNALSYM PWTS_PROCESS_INFO}
  294. TWtsProcessInfo = TWtsProcessInfoW;
  295. PWtsProcessInfo = PWtsProcessInfoW;
  296. {$ELSE}
  297. WTS_PROCESS_INFO = WTS_PROCESS_INFOA;
  298. {$EXTERNALSYM WTS_PROCESS_INFO}
  299. PWTS_PROCESS_INFO = PWTS_PROCESS_INFOA;
  300. {$EXTERNALSYM PWTS_PROCESS_INFO}
  301. TWtsProcessInfo = TWtsProcessInfoA;
  302. PWtsProcessInfo = PWtsProcessInfoA;
  303. {$ENDIF UNICODE}
  304. //==============================================================================
  305. // WTS_INFO_CLASS - WTSQuerySessionInformation
  306. // (See additional typedefs for more info on structures)
  307. //==============================================================================
  308. const
  309. WTS_PROTOCOL_TYPE_CONSOLE = 0; // Console
  310. {$EXTERNALSYM WTS_PROTOCOL_TYPE_CONSOLE}
  311. WTS_PROTOCOL_TYPE_ICA = 1; // ICA Protocol
  312. {$EXTERNALSYM WTS_PROTOCOL_TYPE_ICA}
  313. WTS_PROTOCOL_TYPE_RDP = 2; // RDP Protocol
  314. {$EXTERNALSYM WTS_PROTOCOL_TYPE_RDP}
  315. type
  316. _WTS_INFO_CLASS = (
  317. WTSInitialProgram,
  318. WTSApplicationName,
  319. WTSWorkingDirectory,
  320. WTSOEMId,
  321. WTSSessionId,
  322. WTSUserName,
  323. WTSWinStationName,
  324. WTSDomainName,
  325. WTSConnectState,
  326. WTSClientBuildNumber,
  327. WTSClientName,
  328. WTSClientDirectory,
  329. WTSClientProductId,
  330. WTSClientHardwareId,
  331. WTSClientAddress,
  332. WTSClientDisplay,
  333. WTSClientProtocolType);
  334. {$EXTERNALSYM _WTS_INFO_CLASS}
  335. WTS_INFO_CLASS = _WTS_INFO_CLASS;
  336. TWtsInfoClass = WTS_INFO_CLASS;
  337. //==============================================================================
  338. // WTSQuerySessionInformation - (WTSClientAddress)
  339. //==============================================================================
  340. type
  341. PWTS_CLIENT_ADDRESS = ^WTS_CLIENT_ADDRESS;
  342. {$EXTERNALSYM PWTS_CLIENT_ADDRESS}
  343. _WTS_CLIENT_ADDRESS = record
  344. AddressFamily: DWORD; // AF_INET, AF_IPX, AF_NETBIOS, AF_UNSPEC
  345. Address: array [0..19] of BYTE; // client network address
  346. end;
  347. {$EXTERNALSYM _WTS_CLIENT_ADDRESS}
  348. WTS_CLIENT_ADDRESS = _WTS_CLIENT_ADDRESS;
  349. {$EXTERNALSYM WTS_CLIENT_ADDRESS}
  350. TWtsClientAddress = WTS_CLIENT_ADDRESS;
  351. PWtsClientAddress = PWTS_CLIENT_ADDRESS;
  352. //==============================================================================
  353. // WTSQuerySessionInformation - (WTSClientDisplay)
  354. //==============================================================================
  355. type
  356. PWTS_CLIENT_DISPLAY = ^WTS_CLIENT_DISPLAY;
  357. {$EXTERNALSYM PWTS_CLIENT_DISPLAY}
  358. _WTS_CLIENT_DISPLAY = record
  359. HorizontalResolution: DWORD; // horizontal dimensions, in pixels
  360. VerticalResolution: DWORD; // vertical dimensions, in pixels
  361. ColorDepth: DWORD; // 1=16, 2=256, 4=64K, 8=16M
  362. end;
  363. {$EXTERNALSYM _WTS_CLIENT_DISPLAY}
  364. WTS_CLIENT_DISPLAY = _WTS_CLIENT_DISPLAY;
  365. {$EXTERNALSYM WTS_CLIENT_DISPLAY}
  366. TWtsClientDisplay = WTS_CLIENT_DISPLAY;
  367. PWtsClientDisplay = PWTS_CLIENT_DISPLAY;
  368. //==============================================================================
  369. // WTS_CONFIG_CLASS - WTSQueryUserConfig/WTSSetUserConfig
  370. //==============================================================================
  371. type
  372. _WTS_CONFIG_CLASS = (
  373. //Initial program settings
  374. WTSUserConfigInitialProgram, // string returned/expected
  375. WTSUserConfigWorkingDirectory, // string returned/expected
  376. WTSUserConfigfInheritInitialProgram, // DWORD returned/expected
  377. //
  378. WTSUserConfigfAllowLogonTerminalServer, //DWORD returned/expected
  379. //Timeout settings
  380. WTSUserConfigTimeoutSettingsConnections, //DWORD returned/expected
  381. WTSUserConfigTimeoutSettingsDisconnections, //DWORD returned/expected
  382. WTSUserConfigTimeoutSettingsIdle, //DWORD returned/expected
  383. //Client device settings
  384. WTSUserConfigfDeviceClientDrives, //DWORD returned/expected
  385. WTSUserConfigfDeviceClientPrinters, //DWORD returned/expected
  386. WTSUserConfigfDeviceClientDefaultPrinter, //DWORD returned/expected
  387. //Connection settings
  388. WTSUserConfigBrokenTimeoutSettings, //DWORD returned/expected
  389. WTSUserConfigReconnectSettings, //DWORD returned/expected
  390. //Modem settings
  391. WTSUserConfigModemCallbackSettings, //DWORD returned/expected
  392. WTSUserConfigModemCallbackPhoneNumber, // string returned/expected
  393. //Shadow settings
  394. WTSUserConfigShadowingSettings, //DWORD returned/expected
  395. //User Profile settings
  396. WTSUserConfigTerminalServerProfilePath, // string returned/expected
  397. //Terminal Server home directory
  398. WTSUserConfigTerminalServerHomeDir, // string returned/expected
  399. WTSUserConfigTerminalServerHomeDirDrive, // string returned/expected
  400. WTSUserConfigfTerminalServerRemoteHomeDir); // DWORD 0:LOCAL 1:REMOTE
  401. {$EXTERNALSYM _WTS_CONFIG_CLASS}
  402. WTS_CONFIG_CLASS = _WTS_CONFIG_CLASS;
  403. TWtsConfigClass = WTS_CONFIG_CLASS;
  404. {$IFDEF FALSE}
  405. // There we're remove in June 2001 PSDK (pre-release)
  406. PWTS_USER_CONFIG_SET_NWSERVERW = ^WTS_USER_CONFIG_SET_NWSERVERW;
  407. {$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVERW}
  408. _WTS_USER_CONFIG_SET_NWSERVERW = record
  409. pNWServerName: LPWSTR;
  410. pNWDomainAdminName: LPWSTR;
  411. pNWDomainAdminPassword: LPWSTR;
  412. end;
  413. {$EXTERNALSYM _WTS_USER_CONFIG_SET_NWSERVERW}
  414. WTS_USER_CONFIG_SET_NWSERVERW = _WTS_USER_CONFIG_SET_NWSERVERW;
  415. {$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVERW}
  416. TWtsUserConfigSetNwserverW = WTS_USER_CONFIG_SET_NWSERVERW;
  417. PWtsUserConfigSetNwserverW = PWTS_USER_CONFIG_SET_NWSERVERW;
  418. PWTS_USER_CONFIG_SET_NWSERVERA = ^WTS_USER_CONFIG_SET_NWSERVERA;
  419. {$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVERA}
  420. _WTS_USER_CONFIG_SET_NWSERVERA = record
  421. pNWServerName: LPSTR;
  422. pNWDomainAdminName: LPSTR;
  423. pNWDomainAdminPassword: LPSTR;
  424. end;
  425. {$EXTERNALSYM _WTS_USER_CONFIG_SET_NWSERVERA}
  426. WTS_USER_CONFIG_SET_NWSERVERA = _WTS_USER_CONFIG_SET_NWSERVERA;
  427. {$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVERA}
  428. TWtsUserConfigSetNwserverA = WTS_USER_CONFIG_SET_NWSERVERA;
  429. PWtsUserConfigSetNwserverA = PWTS_USER_CONFIG_SET_NWSERVERA;
  430. {$IFDEF UNICODE}
  431. WTS_USER_CONFIG_SET_NWSERVER = WTS_USER_CONFIG_SET_NWSERVERW;
  432. {$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVER}
  433. PWTS_USER_CONFIG_SET_NWSERVER = PWTS_USER_CONFIG_SET_NWSERVERW;
  434. {$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVER}
  435. TWtsUserConfigSetNwserver = TWtsUserConfigSetNwserverW;
  436. PWtsUserConfigSetNwserver = PWtsUserConfigSetNwserverW;
  437. {$ELSE}
  438. WTS_USER_CONFIG_SET_NWSERVER = WTS_USER_CONFIG_SET_NWSERVERA;
  439. {$EXTERNALSYM WTS_USER_CONFIG_SET_NWSERVER}
  440. PWTS_USER_CONFIG_SET_NWSERVER = PWTS_USER_CONFIG_SET_NWSERVERA;
  441. {$EXTERNALSYM PWTS_USER_CONFIG_SET_NWSERVER}
  442. TWtsUserConfigSetNwserver = TWtsUserConfigSetNwserverA;
  443. PWtsUserConfigSetNwserver = PWtsUserConfigSetNwserverA;
  444. {$ENDIF UNICODE}
  445. {$ENDIF FALSE}
  446. //==============================================================================
  447. // WTS_EVENT - Event flags for WTSWaitSystemEvent
  448. //==============================================================================
  449. const
  450. WTS_EVENT_NONE = $00000000; // return no event
  451. {$EXTERNALSYM WTS_EVENT_NONE}
  452. WTS_EVENT_CREATE = $00000001; // new WinStation created
  453. {$EXTERNALSYM WTS_EVENT_CREATE}
  454. WTS_EVENT_DELETE = $00000002; // existing WinStation deleted
  455. {$EXTERNALSYM WTS_EVENT_DELETE}
  456. WTS_EVENT_RENAME = $00000004; // existing WinStation renamed
  457. {$EXTERNALSYM WTS_EVENT_RENAME}
  458. WTS_EVENT_CONNECT = $00000008; // WinStation connect to client
  459. {$EXTERNALSYM WTS_EVENT_CONNECT}
  460. WTS_EVENT_DISCONNECT = $00000010; // WinStation logged on without client
  461. {$EXTERNALSYM WTS_EVENT_DISCONNECT}
  462. WTS_EVENT_LOGON = $00000020; // user logged on to existing WinStation
  463. {$EXTERNALSYM WTS_EVENT_LOGON}
  464. WTS_EVENT_LOGOFF = $00000040; // user logged off from existing WinStation
  465. {$EXTERNALSYM WTS_EVENT_LOGOFF}
  466. WTS_EVENT_STATECHANGE = $00000080; // WinStation state change
  467. {$EXTERNALSYM WTS_EVENT_STATECHANGE}
  468. WTS_EVENT_LICENSE = $00000100; // license state change
  469. {$EXTERNALSYM WTS_EVENT_LICENSE}
  470. WTS_EVENT_ALL = $7fffffff; // wait for all event types
  471. {$EXTERNALSYM WTS_EVENT_ALL}
  472. WTS_EVENT_FLUSH = DWORD($80000000); // unblock all waiters
  473. {$EXTERNALSYM WTS_EVENT_FLUSH}
  474. //==============================================================================
  475. // WTS_VIRTUAL_CLASS - WTSVirtualChannelQuery
  476. //==============================================================================
  477. type
  478. _WTS_VIRTUAL_CLASS = (WTSVirtualClientData, WTSVirtualFileHandle);
  479. {$EXTERNALSYM _WTS_VIRTUAL_CLASS}
  480. WTS_VIRTUAL_CLASS = _WTS_VIRTUAL_CLASS;
  481. {$EXTERNALSYM WTS_VIRTUAL_CLASS}
  482. TWtsVirtualClass = WTS_VIRTUAL_CLASS;
  483. //==============================================================================
  484. // Windows Terminal Server public APIs
  485. //==============================================================================
  486. function WTSEnumerateServersA(pDomainName: LPSTR; Reserved, Version: DWORD;
  487. var ppServerInfo: PWTS_SERVER_INFOA; var pCount: DWORD): BOOL; stdcall;
  488. {$EXTERNALSYM WTSEnumerateServersA}
  489. function WTSEnumerateServersW(pDomainName: LPWSTR; Reserved, Version: DWORD;
  490. var ppServerInfo: PWTS_SERVER_INFOW; var pCount: DWORD): BOOL; stdcall;
  491. {$EXTERNALSYM WTSEnumerateServersW}
  492. function WTSEnumerateServers(pDomainName: LPTSTR; Reserved, Version: DWORD;
  493. var ppServerInfo: PWTS_SERVER_INFO; var pCount: DWORD): BOOL; stdcall;
  494. {$EXTERNALSYM WTSEnumerateServers}
  495. //------------------------------------------------------------------------------
  496. function WTSOpenServerA(pServerName: LPSTR): HANDLE; stdcall;
  497. {$EXTERNALSYM WTSOpenServerA}
  498. function WTSOpenServerW(pServerName: LPWSTR): HANDLE; stdcall;
  499. {$EXTERNALSYM WTSOpenServerW}
  500. function WTSOpenServer(pServerName: LPTSTR): HANDLE; stdcall;
  501. {$EXTERNALSYM WTSOpenServer}
  502. //------------------------------------------------------------------------------
  503. procedure WTSCloseServer(hServer: HANDLE); stdcall;
  504. {$EXTERNALSYM WTSCloseServer}
  505. //------------------------------------------------------------------------------
  506. function WTSEnumerateSessionsA(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  507. var ppSessionInfo: PWTS_SESSION_INFOA; var pCount: DWORD): BOOL; stdcall;
  508. {$EXTERNALSYM WTSEnumerateSessionsA}
  509. function WTSEnumerateSessionsW(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  510. var ppSessionInfo: PWTS_SESSION_INFOW; var pCount: DWORD): BOOL; stdcall;
  511. {$EXTERNALSYM WTSEnumerateSessionsW}
  512. function WTSEnumerateSessions(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  513. var ppSessionInfo: PWTS_SESSION_INFO; var pCount: DWORD): BOOL; stdcall;
  514. {$EXTERNALSYM WTSEnumerateSessions}
  515. //------------------------------------------------------------------------------
  516. function WTSEnumerateProcessesA(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  517. var ppProcessInfo: PWTS_PROCESS_INFOA; var pCount: DWORD): BOOL; stdcall;
  518. {$EXTERNALSYM WTSEnumerateProcessesA}
  519. function WTSEnumerateProcessesW(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  520. var ppProcessInfo: PWTS_PROCESS_INFOW; var pCount: DWORD): BOOL; stdcall;
  521. {$EXTERNALSYM WTSEnumerateProcessesW}
  522. function WTSEnumerateProcesses(hServer: HANDLE; Reserved: DWORD; Version: DWORD;
  523. var ppProcessInfo: PWTS_PROCESS_INFO; var pCount: DWORD): BOOL; stdcall;
  524. {$EXTERNALSYM WTSEnumerateProcesses}
  525. //------------------------------------------------------------------------------
  526. function WTSTerminateProcess(hServer: HANDLE; ProcessId, ExitCode: DWORD): BOOL; stdcall;
  527. {$EXTERNALSYM WTSTerminateProcess}
  528. //------------------------------------------------------------------------------
  529. function WTSQuerySessionInformationA(hServer: HANDLE; SessionId: DWORD;
  530. WTSInfoClass: WTS_INFO_CLASS; var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  531. {$EXTERNALSYM WTSQuerySessionInformationA}
  532. function WTSQuerySessionInformationW(hServer: HANDLE; SessionId: DWORD;
  533. WTSInfoClass: WTS_INFO_CLASS; var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  534. {$EXTERNALSYM WTSQuerySessionInformationW}
  535. function WTSQuerySessionInformation(hServer: HANDLE; SessionId: DWORD;
  536. WTSInfoClass: WTS_INFO_CLASS; var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  537. {$EXTERNALSYM WTSQuerySessionInformation}
  538. //------------------------------------------------------------------------------
  539. function WTSQueryUserConfigA(pServerName, pUserName: LPSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  540. var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  541. {$EXTERNALSYM WTSQueryUserConfigA}
  542. function WTSQueryUserConfigW(pServerName, pUserName: LPWSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  543. var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  544. {$EXTERNALSYM WTSQueryUserConfigW}
  545. function WTSQueryUserConfig(pServerName, pUserName: LPTSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  546. var ppBuffer: Pointer; var pBytesReturned: DWORD): BOOL; stdcall;
  547. {$EXTERNALSYM WTSQueryUserConfig}
  548. //------------------------------------------------------------------------------
  549. function WTSSetUserConfigA(pServerName, pUserName: LPSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  550. pBuffer: LPSTR; DataLength: DWORD): BOOL; stdcall;
  551. {$EXTERNALSYM WTSSetUserConfigA}
  552. function WTSSetUserConfigW(pServerName, pUserName: LPWSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  553. pBuffer: LPWSTR; DataLength: DWORD): BOOL; stdcall;
  554. {$EXTERNALSYM WTSSetUserConfigW}
  555. function WTSSetUserConfig(pServerName, pUserName: LPTSTR; WTSConfigClass: WTS_CONFIG_CLASS;
  556. pBuffer: LPTSTR; DataLength: DWORD): BOOL; stdcall;
  557. {$EXTERNALSYM WTSSetUserConfig}
  558. //------------------------------------------------------------------------------
  559. function WTSSendMessageA(hServer: HANDLE; SessionId: DWORD; pTitle: LPSTR;
  560. TitleLength: DWORD; pMessage: LPSTR; MessageLength: DWORD; Style: DWORD;
  561. Timeout: DWORD; var pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
  562. {$EXTERNALSYM WTSSendMessageA}
  563. function WTSSendMessageW(hServer: HANDLE; SessionId: DWORD; pTitle: LPWSTR;
  564. TitleLength: DWORD; pMessage: LPWSTR; MessageLength: DWORD; Style: DWORD;
  565. Timeout: DWORD; var pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
  566. {$EXTERNALSYM WTSSendMessageW}
  567. function WTSSendMessage(hServer: HANDLE; SessionId: DWORD; pTitle: LPTSTR;
  568. TitleLength: DWORD; pMessage: LPTSTR; MessageLength: DWORD; Style: DWORD;
  569. Timeout: DWORD; var pResponse: DWORD; bWait: BOOL): BOOL; stdcall;
  570. {$EXTERNALSYM WTSSendMessage}
  571. //------------------------------------------------------------------------------
  572. function WTSDisconnectSession(hServer: HANDLE; SessionId: DWORD; bWait: BOOL): BOOL; stdcall;
  573. {$EXTERNALSYM WTSDisconnectSession}
  574. //------------------------------------------------------------------------------
  575. function WTSLogoffSession(hServer: HANDLE; SessionId: DWORD; bWait: BOOL): BOOL; stdcall;
  576. {$EXTERNALSYM WTSLogoffSession}
  577. //------------------------------------------------------------------------------
  578. function WTSShutdownSystem(hServer: HANDLE; ShutdownFlag: DWORD): BOOL; stdcall;
  579. {$EXTERNALSYM WTSShutdownSystem}
  580. //------------------------------------------------------------------------------
  581. function WTSWaitSystemEvent(hServer: HANDLE; EventMask: DWORD;
  582. var pEventFlags: DWORD): BOOL; stdcall;
  583. {$EXTERNALSYM WTSWaitSystemEvent}
  584. //------------------------------------------------------------------------------
  585. function WTSVirtualChannelOpen(hServer: HANDLE; SessionId: DWORD;
  586. pVirtualName: LPSTR): HANDLE; stdcall;
  587. {$EXTERNALSYM WTSVirtualChannelOpen}
  588. function WTSVirtualChannelClose(hChannelHandle: HANDLE): BOOL; stdcall;
  589. {$EXTERNALSYM WTSVirtualChannelClose}
  590. function WTSVirtualChannelRead(hChannelHandle: HANDLE; TimeOut: ULONG;
  591. Buffer: PCHAR; BufferSize: ULONG; var pBytesRead: ULONG): BOOL; stdcall;
  592. {$EXTERNALSYM WTSVirtualChannelRead}
  593. function WTSVirtualChannelWrite(hChannelHandle: HANDLE; Buffer: PCHAR;
  594. Length: ULONG; var pBytesWritten: ULONG): BOOL; stdcall;
  595. {$EXTERNALSYM WTSVirtualChannelWrite}
  596. function WTSVirtualChannelPurgeInput(hChannelHandle: HANDLE): BOOL; stdcall;
  597. {$EXTERNALSYM WTSVirtualChannelPurgeInput}
  598. function WTSVirtualChannelPurgeOutput(hChannelHandle: HANDLE): BOOL; stdcall;
  599. {$EXTERNALSYM WTSVirtualChannelPurgeOutput}
  600. function WTSVirtualChannelQuery(hChannelHandle: HANDLE; VirtualClass: WTS_VIRTUAL_CLASS;
  601. ppBuffer: PVOID; var pBytesReturned: DWORD): BOOL; stdcall;
  602. {$EXTERNALSYM WTSVirtualChannelQuery}
  603. //------------------------------------------------------------------------------
  604. procedure WTSFreeMemory(pMemory: PVOID); stdcall;
  605. {$EXTERNALSYM WTSFreeMemory}
  606. // Flags for Console Notification
  607. const
  608. NOTIFY_FOR_ALL_SESSIONS = 1;
  609. {$EXTERNALSYM NOTIFY_FOR_ALL_SESSIONS}
  610. NOTIFY_FOR_THIS_SESSION = 0;
  611. {$EXTERNALSYM NOTIFY_FOR_THIS_SESSION}
  612. function WTSRegisterSessionNotification(hWnd: HWND; dwFlags: DWORD): BOOL; stdcall;
  613. {$EXTERNALSYM WTSRegisterSessionNotification}
  614. function WTSUnRegisterSessionNotification(hWnd: HWND): BOOL; stdcall;
  615. {$EXTERNALSYM WTSUnRegisterSessionNotification}
  616. function WTSQueryUserToken(SessionId: ULONG; var phToken: HANDLE): BOOL; stdcall;
  617. {$EXTERNALSYM WTSQueryUserToken}
  618. implementation
  619. const
  620. wtsapi = 'wtsapi32.dll';
  621. {$IFDEF UNICODE}
  622. AWSuffix = 'W';
  623. {$ELSE}
  624. AWSuffix = 'A';
  625. {$ENDIF UNICODE}
  626. {$IFDEF DYNAMIC_LINK}
  627. var
  628. _WTSEnumerateServersA: Pointer;
  629. function WTSEnumerateServersA;
  630. begin
  631. GetProcedureAddress(_WTSEnumerateServersA, wtsapi, 'WTSEnumerateServersA');
  632. asm
  633. MOV ESP, EBP
  634. POP EBP
  635. JMP [_WTSEnumerateServersA]
  636. end;
  637. end;
  638. var
  639. _WTSEnumerateServersW: Pointer;
  640. function WTSEnumerateServersW;
  641. begin
  642. GetProcedureAddress(_WTSEnumerateServersW, wtsapi, 'WTSEnumerateServersW');
  643. asm
  644. MOV ESP, EBP
  645. POP EBP
  646. JMP [_WTSEnumerateServersW]
  647. end;
  648. end;
  649. var
  650. _WTSEnumerateServers: Pointer;
  651. function WTSEnumerateServers;
  652. begin
  653. GetProcedureAddress(_WTSEnumerateServers, wtsapi, 'WTSEnumerateServers' + AWSuffix);
  654. asm
  655. MOV ESP, EBP
  656. POP EBP
  657. JMP [_WTSEnumerateServers]
  658. end;
  659. end;
  660. var
  661. _WTSOpenServerA: Pointer;
  662. function WTSOpenServerA;
  663. begin
  664. GetProcedureAddress(_WTSOpenServerA, wtsapi, 'WTSOpenServerA');
  665. asm
  666. MOV ESP, EBP
  667. POP EBP
  668. JMP [_WTSOpenServerA]
  669. end;
  670. end;
  671. var
  672. _WTSOpenServerW: Pointer;
  673. function WTSOpenServerW;
  674. begin
  675. GetProcedureAddress(_WTSOpenServerW, wtsapi, 'WTSOpenServerW');
  676. asm
  677. MOV ESP, EBP
  678. POP EBP
  679. JMP [_WTSOpenServerW]
  680. end;
  681. end;
  682. var
  683. _WTSOpenServer: Pointer;
  684. function WTSOpenServer;
  685. begin
  686. GetProcedureAddress(_WTSOpenServer, wtsapi, 'WTSOpenServer' + AWSuffix);
  687. asm
  688. MOV ESP, EBP
  689. POP EBP
  690. JMP [_WTSOpenServer]
  691. end;
  692. end;
  693. var
  694. _WTSCloseServer: Pointer;
  695. procedure WTSCloseServer;
  696. begin
  697. GetProcedureAddress(_WTSCloseServer, wtsapi, 'WTSCloseServer');
  698. asm
  699. MOV ESP, EBP
  700. POP EBP
  701. JMP [_WTSCloseServer]
  702. end;
  703. end;
  704. var
  705. _WTSEnumerateSessionsA: Pointer;
  706. function WTSEnumerateSessionsA;
  707. begin
  708. GetProcedureAddress(_WTSEnumerateSessionsA, wtsapi, 'WTSEnumerateSessionsA');
  709. asm
  710. MOV ESP, EBP
  711. POP EBP
  712. JMP [_WTSEnumerateSessionsA]
  713. end;
  714. end;
  715. var
  716. _WTSEnumerateSessionsW: Pointer;
  717. function WTSEnumerateSessionsW;
  718. begin
  719. GetProcedureAddress(_WTSEnumerateSessionsW, wtsapi, 'WTSEnumerateSessionsW');
  720. asm
  721. MOV ESP, EBP
  722. POP EBP
  723. JMP [_WTSEnumerateSessionsW]
  724. end;
  725. end;
  726. var
  727. _WTSEnumerateSessions: Pointer;
  728. function WTSEnumerateSessions;
  729. begin
  730. GetProcedureAddress(_WTSEnumerateSessions, wtsapi, 'WTSEnumerateSessions' + AWSuffix);
  731. asm
  732. MOV ESP, EBP
  733. POP EBP
  734. JMP [_WTSEnumerateSessions]
  735. end;
  736. end;
  737. var
  738. _WTSEnumerateProcessesA: Pointer;
  739. function WTSEnumerateProcessesA;
  740. begin
  741. GetProcedureAddress(_WTSEnumerateProcessesA, wtsapi, 'WTSEnumerateProcessesA');
  742. asm
  743. MOV ESP, EBP
  744. POP EBP
  745. JMP [_WTSEnumerateProcessesA]
  746. end;
  747. end;
  748. var
  749. _WTSEnumerateProcessesW: Pointer;
  750. function WTSEnumerateProcessesW;
  751. begin
  752. GetProcedureAddress(_WTSEnumerateProcessesW, wtsapi, 'WTSEnumerateProcessesW');
  753. asm
  754. MOV ESP, EBP
  755. POP EBP
  756. JMP [_WTSEnumerateProcessesW]
  757. end;
  758. end;
  759. var
  760. _WTSEnumerateProcesses: Pointer;
  761. function WTSEnumerateProcesses;
  762. begin
  763. GetProcedureAddress(_WTSEnumerateProcesses, wtsapi, 'WTSEnumerateProcesses' + AWSuffix);
  764. asm
  765. MOV ESP, EBP
  766. POP EBP
  767. JMP [_WTSEnumerateProcesses]
  768. end;
  769. end;
  770. var
  771. _WTSTerminateProcess: Pointer;
  772. function WTSTerminateProcess;
  773. begin
  774. GetProcedureAddress(_WTSTerminateProcess, wtsapi, 'WTSTerminateProcess');
  775. asm
  776. MOV ESP, EBP
  777. POP EBP
  778. JMP [_WTSTerminateProcess]
  779. end;
  780. end;
  781. var
  782. _WTSQuerySessionInformationA: Pointer;
  783. function WTSQuerySessionInformationA;
  784. begin
  785. GetProcedureAddress(_WTSQuerySessionInformationA, wtsapi, 'WTSQuerySessionInformationA');
  786. asm
  787. MOV ESP, EBP
  788. POP EBP
  789. JMP [_WTSQuerySessionInformationA]
  790. end;
  791. end;
  792. var
  793. _WTSQuerySessionInformationW: Pointer;
  794. function WTSQuerySessionInformationW;
  795. begin
  796. GetProcedureAddress(_WTSQuerySessionInformationW, wtsapi, 'WTSQuerySessionInformationW');
  797. asm
  798. MOV ESP, EBP
  799. POP EBP
  800. JMP [_WTSQuerySessionInformationW]
  801. end;
  802. end;
  803. var
  804. _WTSQuerySessionInformation: Pointer;
  805. function WTSQuerySessionInformation;
  806. begin
  807. GetProcedureAddress(_WTSQuerySessionInformation, wtsapi, 'WTSQuerySessionInformation' + AWSuffix);
  808. asm
  809. MOV ESP, EBP
  810. POP EBP
  811. JMP [_WTSQuerySessionInformation]
  812. end;
  813. end;
  814. var
  815. _WTSQueryUserConfigA: Pointer;
  816. function WTSQueryUserConfigA;
  817. begin
  818. GetProcedureAddress(_WTSQueryUserConfigA, wtsapi, 'WTSQueryUserConfigA');
  819. asm
  820. MOV ESP, EBP
  821. POP EBP
  822. JMP [_WTSQueryUserConfigA]
  823. end;
  824. end;
  825. var
  826. _WTSQueryUserConfigW: Pointer;
  827. function WTSQueryUserConfigW;
  828. begin
  829. GetProcedureAddress(_WTSQueryUserConfigW, wtsapi, 'WTSQueryUserConfigW');
  830. asm
  831. MOV ESP, EBP
  832. POP EBP
  833. JMP [_WTSQueryUserConfigW]
  834. end;
  835. end;
  836. var
  837. _WTSQueryUserConfig: Pointer;
  838. function WTSQueryUserConfig;
  839. begin
  840. GetProcedureAddress(_WTSQueryUserConfig, wtsapi, 'WTSQueryUserConfig' + AWSuffix);
  841. asm
  842. MOV ESP, EBP
  843. POP EBP
  844. JMP [_WTSQueryUserConfig]
  845. end;
  846. end;
  847. var
  848. _WTSSetUserConfigA: Pointer;
  849. function WTSSetUserConfigA;
  850. begin
  851. GetProcedureAddress(_WTSSetUserConfigA, wtsapi, 'WTSSetUserConfigA');
  852. asm
  853. MOV ESP, EBP
  854. POP EBP
  855. JMP [_WTSSetUserConfigA]
  856. end;
  857. end;
  858. var
  859. _WTSSetUserConfigW: Pointer;
  860. function WTSSetUserConfigW;
  861. begin
  862. GetProcedureAddress(_WTSSetUserConfigW, wtsapi, 'WTSSetUserConfigW');
  863. asm
  864. MOV ESP, EBP
  865. POP EBP
  866. JMP [_WTSSetUserConfigW]
  867. end;
  868. end;
  869. var
  870. _WTSSetUserConfig: Pointer;
  871. function WTSSetUserConfig;
  872. begin
  873. GetProcedureAddress(_WTSSetUserConfig, wtsapi, 'WTSSetUserConfig' + AWSuffix);
  874. asm
  875. MOV ESP, EBP
  876. POP EBP
  877. JMP [_WTSSetUserConfig]
  878. end;
  879. end;
  880. var
  881. _WTSSendMessageA: Pointer;
  882. function WTSSendMessageA;
  883. begin
  884. GetProcedureAddress(_WTSSendMessageA, wtsapi, 'WTSSendMessageA');
  885. asm
  886. MOV ESP, EBP
  887. POP EBP
  888. JMP [_WTSSendMessageA]
  889. end;
  890. end;
  891. var
  892. _WTSSendMessageW: Pointer;
  893. function WTSSendMessageW;
  894. begin
  895. GetProcedureAddress(_WTSSendMessageW, wtsapi, 'WTSSendMessageW');
  896. asm
  897. MOV ESP, EBP
  898. POP EBP
  899. JMP [_WTSSendMessageW]
  900. end;
  901. end;
  902. var
  903. _WTSSendMessage: Pointer;
  904. function WTSSendMessage;
  905. begin
  906. GetProcedureAddress(_WTSSendMessage, wtsapi, 'WTSSendMessage' + AWSuffix);
  907. asm
  908. MOV ESP, EBP
  909. POP EBP
  910. JMP [_WTSSendMessage]
  911. end;
  912. end;
  913. var
  914. _WTSDisconnectSession: Pointer;
  915. function WTSDisconnectSession;
  916. begin
  917. GetProcedureAddress(_WTSDisconnectSession, wtsapi, 'WTSDisconnectSession');
  918. asm
  919. MOV ESP, EBP
  920. POP EBP
  921. JMP [_WTSDisconnectSession]
  922. end;
  923. end;
  924. var
  925. _WTSLogoffSession: Pointer;
  926. function WTSLogoffSession;
  927. begin
  928. GetProcedureAddress(_WTSLogoffSession, wtsapi, 'WTSLogoffSession');
  929. asm
  930. MOV ESP, EBP
  931. POP EBP
  932. JMP [_WTSLogoffSession]
  933. end;
  934. end;
  935. var
  936. _WTSShutdownSystem: Pointer;
  937. function WTSShutdownSystem;
  938. begin
  939. GetProcedureAddress(_WTSShutdownSystem, wtsapi, 'WTSShutdownSystem');
  940. asm
  941. MOV ESP, EBP
  942. POP EBP
  943. JMP [_WTSShutdownSystem]
  944. end;
  945. end;
  946. var
  947. _WTSWaitSystemEvent: Pointer;
  948. function WTSWaitSystemEvent;
  949. begin
  950. GetProcedureAddress(_WTSWaitSystemEvent, wtsapi, 'WTSWaitSystemEvent');
  951. asm
  952. MOV ESP, EBP
  953. POP EBP
  954. JMP [_WTSWaitSystemEvent]
  955. end;
  956. end;
  957. var
  958. _WTSVirtualChannelOpen: Pointer;
  959. function WTSVirtualChannelOpen;
  960. begin
  961. GetProcedureAddress(_WTSVirtualChannelOpen, wtsapi, 'WTSVirtualChannelOpen');
  962. asm
  963. MOV ESP, EBP
  964. POP EBP
  965. JMP [_WTSVirtualChannelOpen]
  966. end;
  967. end;
  968. var
  969. _WTSVirtualChannelClose: Pointer;
  970. function WTSVirtualChannelClose;
  971. begin
  972. GetProcedureAddress(_WTSVirtualChannelClose, wtsapi, 'WTSVirtualChannelClose');
  973. asm
  974. MOV ESP, EBP
  975. POP EBP
  976. JMP [_WTSVirtualChannelClose]
  977. end;
  978. end;
  979. var
  980. _WTSVirtualChannelRead: Pointer;
  981. function WTSVirtualChannelRead;
  982. begin
  983. GetProcedureAddress(_WTSVirtualChannelRead, wtsapi, 'WTSVirtualChannelRead');
  984. asm
  985. MOV ESP, EBP
  986. POP EBP
  987. JMP [_WTSVirtualChannelRead]
  988. end;
  989. end;
  990. var
  991. _WTSVirtualChannelWrite: Pointer;
  992. function WTSVirtualChannelWrite;
  993. begin
  994. GetProcedureAddress(_WTSVirtualChannelWrite, wtsapi, 'WTSVirtualChannelWrite');
  995. asm
  996. MOV ESP, EBP
  997. POP EBP
  998. JMP [_WTSVirtualChannelWrite]
  999. end;
  1000. end;
  1001. var
  1002. _WTSVirtualChannelPurgeInput: Pointer;
  1003. function WTSVirtualChannelPurgeInput;
  1004. begin
  1005. GetProcedureAddress(_WTSVirtualChannelPurgeInput, wtsapi, 'WTSVirtualChannelPurgeInput');
  1006. asm
  1007. MOV ESP, EBP
  1008. POP EBP
  1009. JMP [_WTSVirtualChannelPurgeInput]
  1010. end;
  1011. end;
  1012. var
  1013. _WTSVirtualChannelPurgeOutput: Pointer;
  1014. function WTSVirtualChannelPurgeOutput;
  1015. begin
  1016. GetProcedureAddress(_WTSVirtualChannelPurgeOutput, wtsapi, 'WTSVirtualChannelPurgeOutput');
  1017. asm
  1018. MOV ESP, EBP
  1019. POP EBP
  1020. JMP [_WTSVirtualChannelPurgeOutput]
  1021. end;
  1022. end;
  1023. var
  1024. _WTSVirtualChannelQuery: Pointer;
  1025. function WTSVirtualChannelQuery;
  1026. begin
  1027. GetProcedureAddress(_WTSVirtualChannelQuery, wtsapi, 'WTSVirtualChannelQuery');
  1028. asm
  1029. MOV ESP, EBP
  1030. POP EBP
  1031. JMP [_WTSVirtualChannelQuery]
  1032. end;
  1033. end;
  1034. var
  1035. _WTSFreeMemory: Pointer;
  1036. procedure WTSFreeMemory;
  1037. begin
  1038. GetProcedureAddress(_WTSFreeMemory, wtsapi, 'WTSFreeMemory');
  1039. asm
  1040. MOV ESP, EBP
  1041. POP EBP
  1042. JMP [_WTSFreeMemory]
  1043. end;
  1044. end;
  1045. var
  1046. _WTSRegisterSessionNotification: Pointer;
  1047. function WTSRegisterSessionNotification;
  1048. begin
  1049. GetProcedureAddress(_WTSRegisterSessionNotification, wtsapi, 'WTSRegisterSessionNotification');
  1050. asm
  1051. MOV ESP, EBP
  1052. POP EBP
  1053. JMP [_WTSRegisterSessionNotification]
  1054. end;
  1055. end;
  1056. var
  1057. _WTSUnRegisterSessionNot: Pointer;
  1058. function WTSUnRegisterSessionNotification;
  1059. begin
  1060. GetProcedureAddress(_WTSUnRegisterSessionNot, wtsapi, 'WTSUnRegisterSessionNotification');
  1061. asm
  1062. MOV ESP, EBP
  1063. POP EBP
  1064. JMP [_WTSUnRegisterSessionNot]
  1065. end;
  1066. end;
  1067. var
  1068. _WTSQueryUserToken: Pointer;
  1069. function WTSQueryUserToken;
  1070. begin
  1071. GetProcedureAddress(_WTSQueryUserToken, wtsapi, 'WTSQueryUserToken');
  1072. asm
  1073. MOV ESP, EBP
  1074. POP EBP
  1075. JMP [_WTSQueryUserToken]
  1076. end;
  1077. end;
  1078. {$ELSE}
  1079. function WTSEnumerateServersA; external wtsapi name 'WTSEnumerateServersA';
  1080. function WTSEnumerateServersW; external wtsapi name 'WTSEnumerateServersW';
  1081. function WTSEnumerateServers; external wtsapi name 'WTSEnumerateServers' + AWSuffix;
  1082. function WTSOpenServerA; external wtsapi name 'WTSOpenServerA';
  1083. function WTSOpenServerW; external wtsapi name 'WTSOpenServerW';
  1084. function WTSOpenServer; external wtsapi name 'WTSOpenServer' + AWSuffix;
  1085. procedure WTSCloseServer; external wtsapi name 'WTSCloseServer';
  1086. function WTSEnumerateSessionsA; external wtsapi name 'WTSEnumerateSessionsA';
  1087. function WTSEnumerateSessionsW; external wtsapi name 'WTSEnumerateSessionsW';
  1088. function WTSEnumerateSessions; external wtsapi name 'WTSEnumerateSessions' + AWSuffix;
  1089. function WTSEnumerateProcessesA; external wtsapi name 'WTSEnumerateProcessesA';
  1090. function WTSEnumerateProcessesW; external wtsapi name 'WTSEnumerateProcessesW';
  1091. function WTSEnumerateProcesses; external wtsapi name 'WTSEnumerateProcesses' + AWSuffix;
  1092. function WTSTerminateProcess; external wtsapi name 'WTSTerminateProcess';
  1093. function WTSQuerySessionInformationA; external wtsapi name 'WTSQuerySessionInformationA';
  1094. function WTSQuerySessionInformationW; external wtsapi name 'WTSQuerySessionInformationW';
  1095. function WTSQuerySessionInformation; external wtsapi name 'WTSQuerySessionInformation' + AWSuffix;
  1096. function WTSQueryUserConfigA; external wtsapi name 'WTSQueryUserConfigA';
  1097. function WTSQueryUserConfigW; external wtsapi name 'WTSQueryUserConfigW';
  1098. function WTSQueryUserConfig; external wtsapi name 'WTSQueryUserConfig' + AWSuffix;
  1099. function WTSSetUserConfigA; external wtsapi name 'WTSSetUserConfigA';
  1100. function WTSSetUserConfigW; external wtsapi name 'WTSSetUserConfigW';
  1101. function WTSSetUserConfig; external wtsapi name 'WTSSetUserConfig' + AWSuffix;
  1102. function WTSSendMessageA; external wtsapi name 'WTSSendMessageA';
  1103. function WTSSendMessageW; external wtsapi name 'WTSSendMessageW';
  1104. function WTSSendMessage; external wtsapi name 'WTSSendMessage' + AWSuffix;
  1105. function WTSDisconnectSession; external wtsapi name 'WTSDisconnectSession';
  1106. function WTSLogoffSession; external wtsapi name 'WTSLogoffSession';
  1107. function WTSShutdownSystem; external wtsapi name 'WTSShutdownSystem';
  1108. function WTSWaitSystemEvent; external wtsapi name 'WTSWaitSystemEvent';
  1109. function WTSVirtualChannelOpen; external wtsapi name 'WTSVirtualChannelOpen';
  1110. function WTSVirtualChannelClose; external wtsapi name 'WTSVirtualChannelClose';
  1111. function WTSVirtualChannelRead; external wtsapi name 'WTSVirtualChannelRead';
  1112. function WTSVirtualChannelWrite; external wtsapi name 'WTSVirtualChannelWrite';
  1113. function WTSVirtualChannelPurgeInput; external wtsapi name 'WTSVirtualChannelPurgeInput';
  1114. function WTSVirtualChannelPurgeOutput; external wtsapi name 'WTSVirtualChannelPurgeOutput';
  1115. function WTSVirtualChannelQuery; external wtsapi name 'WTSVirtualChannelQuery';
  1116. procedure WTSFreeMemory; external wtsapi name 'WTSFreeMemory';
  1117. function WTSRegisterSessionNotification; external wtsapi name 'WTSRegisterSessionNotification';
  1118. function WTSUnRegisterSessionNotification; external wtsapi name 'WTSUnRegisterSessionNotification';
  1119. function WTSQueryUserToken; external wtsapi name 'WTSQueryUserToken';
  1120. {$ENDIF DYNAMIC_LINK}
  1121. end.