jwalmsvc.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794
  1. {******************************************************************************}
  2. { }
  3. { Lan Manager Service 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: lmsvc.h, released November 2001. The original Pascal }
  9. { code is: LmSvc.pas, released Februari 2002. 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 JwaLmSvc;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "lmsvc.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaLmCons, JwaWinType;
  51. //
  52. // Data Structures
  53. //
  54. type
  55. LPSERVICE_INFO_0 = ^SERVICE_INFO_0;
  56. {$EXTERNALSYM LPSERVICE_INFO_0}
  57. PSERVICE_INFO_0 = ^SERVICE_INFO_0;
  58. {$EXTERNALSYM PSERVICE_INFO_0}
  59. _SERVICE_INFO_0 = record
  60. svci0_name: LPWSTR;
  61. end;
  62. {$EXTERNALSYM _SERVICE_INFO_0}
  63. SERVICE_INFO_0 = _SERVICE_INFO_0;
  64. {$EXTERNALSYM SERVICE_INFO_0}
  65. TServiceInfo0 = SERVICE_INFO_0;
  66. PServiceInfo0 = PSERVICE_INFO_0;
  67. LPSERVICE_INFO_1 = ^SERVICE_INFO_1;
  68. {$EXTERNALSYM LPSERVICE_INFO_1}
  69. PSERVICE_INFO_1 = ^SERVICE_INFO_1;
  70. {$EXTERNALSYM PSERVICE_INFO_1}
  71. _SERVICE_INFO_1 = record
  72. svci1_name: LPWSTR;
  73. svci1_status: DWORD;
  74. svci1_code: DWORD;
  75. svci1_pid: DWORD;
  76. end;
  77. {$EXTERNALSYM _SERVICE_INFO_1}
  78. SERVICE_INFO_1 = _SERVICE_INFO_1;
  79. {$EXTERNALSYM SERVICE_INFO_1}
  80. TServiceInfo1 = SERVICE_INFO_1;
  81. PServiceInfo1 = PSERVICE_INFO_1;
  82. LPSERVICE_INFO_2 = ^SERVICE_INFO_2;
  83. {$EXTERNALSYM LPSERVICE_INFO_2}
  84. PSERVICE_INFO_2 = ^SERVICE_INFO_2;
  85. {$EXTERNALSYM PSERVICE_INFO_2}
  86. _SERVICE_INFO_2 = record
  87. svci2_name: LPWSTR;
  88. svci2_status: DWORD;
  89. svci2_code: DWORD;
  90. svci2_pid: DWORD;
  91. svci2_text: LPWSTR;
  92. svci2_specific_error: DWORD;
  93. svci2_display_name: LPWSTR;
  94. end;
  95. {$EXTERNALSYM _SERVICE_INFO_2}
  96. SERVICE_INFO_2 = _SERVICE_INFO_2;
  97. {$EXTERNALSYM SERVICE_INFO_2}
  98. TServiceInfo2 = SERVICE_INFO_2;
  99. PServiceInfo2 = PSERVICE_INFO_2;
  100. //
  101. // Function Prototypes
  102. //
  103. function NetServiceControl(servername, service: LPCWSTR; opcode: DWORD; arg: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  104. {$EXTERNALSYM NetServiceControl}
  105. function NetServiceEnum(servername: LPCWSTR; level: DWORD; var bufptr: LPBYTE; prefmaxlen: DWORD; entriesread, totalentries, resume_handle: LPDWORD): NET_API_STATUS; stdcall;
  106. {$EXTERNALSYM NetServiceEnum}
  107. function NetServiceGetInfo(servername, service: LPCWSTR; level: DWORD; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  108. {$EXTERNALSYM NetServiceGetInfo}
  109. function NetServiceInstall(servername, service: LPCWSTR; argc: DWORD; argv: LPCWSTR; var bufptr: LPBYTE): NET_API_STATUS; stdcall;
  110. {$EXTERNALSYM NetServiceInstall}
  111. //
  112. // Special Values and Constants
  113. //
  114. //
  115. // Bitmask and bit values for svci1_status, and svci2_status
  116. // fields. For each "subfield", there is a mask defined,
  117. // and a number of constants representing the value
  118. // obtained by doing (status & mask).
  119. //
  120. // Bits 0,1 -- general status
  121. const
  122. SERVICE_INSTALL_STATE = $03;
  123. {$EXTERNALSYM SERVICE_INSTALL_STATE}
  124. SERVICE_UNINSTALLED = $00;
  125. {$EXTERNALSYM SERVICE_UNINSTALLED}
  126. SERVICE_INSTALL_PENDING = $01;
  127. {$EXTERNALSYM SERVICE_INSTALL_PENDING}
  128. SERVICE_UNINSTALL_PENDING = $02;
  129. {$EXTERNALSYM SERVICE_UNINSTALL_PENDING}
  130. SERVICE_INSTALLED = $03;
  131. {$EXTERNALSYM SERVICE_INSTALLED}
  132. // Bits 2,3 -- paused/active status
  133. SERVICE_PAUSE_STATE = $0C;
  134. {$EXTERNALSYM SERVICE_PAUSE_STATE}
  135. LM20_SERVICE_ACTIVE = $00;
  136. {$EXTERNALSYM LM20_SERVICE_ACTIVE}
  137. LM20_SERVICE_CONTINUE_PENDING = $04;
  138. {$EXTERNALSYM LM20_SERVICE_CONTINUE_PENDING}
  139. LM20_SERVICE_PAUSE_PENDING = $08;
  140. {$EXTERNALSYM LM20_SERVICE_PAUSE_PENDING}
  141. LM20_SERVICE_PAUSED = $0C;
  142. {$EXTERNALSYM LM20_SERVICE_PAUSED}
  143. // Bit 4 -- uninstallable indication
  144. SERVICE_NOT_UNINSTALLABLE = $00;
  145. {$EXTERNALSYM SERVICE_NOT_UNINSTALLABLE}
  146. SERVICE_UNINSTALLABLE = $10;
  147. {$EXTERNALSYM SERVICE_UNINSTALLABLE}
  148. // Bit 5 -- pausable indication
  149. SERVICE_NOT_PAUSABLE = $00;
  150. {$EXTERNALSYM SERVICE_NOT_PAUSABLE}
  151. SERVICE_PAUSABLE = $20;
  152. {$EXTERNALSYM SERVICE_PAUSABLE}
  153. // Workstation service only:
  154. // Bits 8,9,10 -- redirection paused/active
  155. SERVICE_REDIR_PAUSED = $700;
  156. {$EXTERNALSYM SERVICE_REDIR_PAUSED}
  157. SERVICE_REDIR_DISK_PAUSED = $100;
  158. {$EXTERNALSYM SERVICE_REDIR_DISK_PAUSED}
  159. SERVICE_REDIR_PRINT_PAUSED = $200;
  160. {$EXTERNALSYM SERVICE_REDIR_PRINT_PAUSED}
  161. SERVICE_REDIR_COMM_PAUSED = $400;
  162. {$EXTERNALSYM SERVICE_REDIR_COMM_PAUSED}
  163. //
  164. // Additional standard LAN Manager for MS-DOS services
  165. //
  166. SERVICE_DOS_ENCRYPTION = WideString('ENCRYPT');
  167. {$EXTERNALSYM SERVICE_DOS_ENCRYPTION}
  168. //
  169. // NetServiceControl opcodes.
  170. //
  171. SERVICE_CTRL_INTERROGATE = 0;
  172. {$EXTERNALSYM SERVICE_CTRL_INTERROGATE}
  173. SERVICE_CTRL_PAUSE = 1;
  174. {$EXTERNALSYM SERVICE_CTRL_PAUSE}
  175. SERVICE_CTRL_CONTINUE = 2;
  176. {$EXTERNALSYM SERVICE_CTRL_CONTINUE}
  177. SERVICE_CTRL_UNINSTALL = 3;
  178. {$EXTERNALSYM SERVICE_CTRL_UNINSTALL}
  179. //
  180. // Workstation service only: Bits used in the "arg" parameter
  181. // to NetServiceControl in conjunction with the opcode
  182. // SERVICE_CTRL_PAUSE or SERVICE_CTRL_CONTINUE, to pause or
  183. // continue redirection.
  184. //
  185. SERVICE_CTRL_REDIR_DISK = $1;
  186. {$EXTERNALSYM SERVICE_CTRL_REDIR_DISK}
  187. SERVICE_CTRL_REDIR_PRINT = $2;
  188. {$EXTERNALSYM SERVICE_CTRL_REDIR_PRINT}
  189. SERVICE_CTRL_REDIR_COMM = $4;
  190. {$EXTERNALSYM SERVICE_CTRL_REDIR_COMM}
  191. //
  192. // Values for svci1_code, and svci2_code when status
  193. // of the service is SERVICE_INSTALL_PENDING or
  194. // SERVICE_UNINSTALL_PENDING.
  195. // A service can optionally provide a hint to the installer
  196. // that the install is proceeding and how long to wait
  197. // (in 0.1 second increments) before querying status again.
  198. //
  199. SERVICE_IP_NO_HINT = $0;
  200. {$EXTERNALSYM SERVICE_IP_NO_HINT}
  201. SERVICE_CCP_NO_HINT = $0;
  202. {$EXTERNALSYM SERVICE_CCP_NO_HINT}
  203. SERVICE_IP_QUERY_HINT = $10000;
  204. {$EXTERNALSYM SERVICE_IP_QUERY_HINT}
  205. SERVICE_CCP_QUERY_HINT = $10000;
  206. {$EXTERNALSYM SERVICE_CCP_QUERY_HINT}
  207. //
  208. // Mask for install proceeding checkpoint number
  209. //
  210. SERVICE_IP_CHKPT_NUM = $0FF;
  211. {$EXTERNALSYM SERVICE_IP_CHKPT_NUM}
  212. SERVICE_CCP_CHKPT_NUM = $0FF;
  213. {$EXTERNALSYM SERVICE_CCP_CHKPT_NUM}
  214. //
  215. // Mask for wait time hint before querying again
  216. //
  217. SERVICE_IP_WAIT_TIME = $0FF00;
  218. {$EXTERNALSYM SERVICE_IP_WAIT_TIME}
  219. SERVICE_CCP_WAIT_TIME = $0FF00;
  220. {$EXTERNALSYM SERVICE_CCP_WAIT_TIME}
  221. //
  222. // Shift count for building wait time _code values
  223. //
  224. SERVICE_IP_WAITTIME_SHIFT = 8;
  225. {$EXTERNALSYM SERVICE_IP_WAITTIME_SHIFT}
  226. SERVICE_NTIP_WAITTIME_SHIFT = 12;
  227. {$EXTERNALSYM SERVICE_NTIP_WAITTIME_SHIFT}
  228. //
  229. // Mask used for upper and lower portions of wait hint time.
  230. //
  231. UPPER_HINT_MASK = $0000FF00;
  232. {$EXTERNALSYM UPPER_HINT_MASK}
  233. LOWER_HINT_MASK = $000000FF;
  234. {$EXTERNALSYM LOWER_HINT_MASK}
  235. UPPER_GET_HINT_MASK = $0FF00000;
  236. {$EXTERNALSYM UPPER_GET_HINT_MASK}
  237. LOWER_GET_HINT_MASK = $0000FF00;
  238. {$EXTERNALSYM LOWER_GET_HINT_MASK}
  239. SERVICE_NT_MAXTIME = $0000FFFF;
  240. {$EXTERNALSYM SERVICE_NT_MAXTIME}
  241. SERVICE_RESRV_MASK = $0001FFFF;
  242. {$EXTERNALSYM SERVICE_RESRV_MASK}
  243. SERVICE_MAXTIME = $000000FF;
  244. {$EXTERNALSYM SERVICE_MAXTIME}
  245. //
  246. // SERVICE_BASE is the base of service error codes,
  247. // chosen to avoid conflict with OS, redirector,
  248. // netapi, and errlog codes.
  249. //
  250. // Don't change the comments following the manifest constants without
  251. // understanding how mapmsg works.
  252. //
  253. SERVICE_BASE = 3050;
  254. {$EXTERNALSYM SERVICE_BASE}
  255. SERVICE_UIC_NORMAL = 0;
  256. {$EXTERNALSYM SERVICE_UIC_NORMAL}
  257. {*
  258. * Uninstall codes, to be used in high byte of 'code' on final NetStatus,
  259. * which sets the status to UNINSTALLED.
  260. *}
  261. SERVICE_UIC_BADPARMVAL = SERVICE_BASE + 1;
  262. {$EXTERNALSYM SERVICE_UIC_BADPARMVAL}
  263. {*
  264. * The Registry or the information you just typed includes an illegal
  265. * value for "%1".
  266. *}
  267. SERVICE_UIC_MISSPARM = SERVICE_BASE + 2;
  268. {$EXTERNALSYM SERVICE_UIC_MISSPARM}
  269. {*
  270. * The required parameter was not provided on the command
  271. * line or in the configuration file.
  272. *}
  273. SERVICE_UIC_UNKPARM = SERVICE_BASE + 3;
  274. {$EXTERNALSYM SERVICE_UIC_UNKPARM}
  275. {*
  276. * LAN Manager does not recognize "%1" as a valid option.
  277. *}
  278. SERVICE_UIC_RESOURCE = SERVICE_BASE + 4;
  279. {$EXTERNALSYM SERVICE_UIC_RESOURCE}
  280. {*
  281. * A request for resource could not be satisfied.
  282. *}
  283. SERVICE_UIC_CONFIG = SERVICE_BASE + 5;
  284. {$EXTERNALSYM SERVICE_UIC_CONFIG}
  285. {*
  286. * A problem exists with the system configuration.
  287. *}
  288. SERVICE_UIC_SYSTEM = SERVICE_BASE + 6;
  289. {$EXTERNALSYM SERVICE_UIC_SYSTEM}
  290. {*
  291. * A system error has occurred.
  292. *}
  293. SERVICE_UIC_INTERNAL = SERVICE_BASE + 7;
  294. {$EXTERNALSYM SERVICE_UIC_INTERNAL}
  295. {*
  296. * An internal consistency error has occurred.
  297. *}
  298. SERVICE_UIC_AMBIGPARM = SERVICE_BASE + 8;
  299. {$EXTERNALSYM SERVICE_UIC_AMBIGPARM}
  300. {*
  301. * The configuration file or the command line has an ambiguous option.
  302. *}
  303. SERVICE_UIC_DUPPARM = SERVICE_BASE + 9;
  304. {$EXTERNALSYM SERVICE_UIC_DUPPARM}
  305. {*
  306. * The configuration file or the command line has a duplicate parameter.
  307. *}
  308. SERVICE_UIC_KILL = SERVICE_BASE + 10;
  309. {$EXTERNALSYM SERVICE_UIC_KILL}
  310. {*
  311. * The service did not respond to control and was stopped with
  312. * the DosKillProc function.
  313. *}
  314. SERVICE_UIC_EXEC = SERVICE_BASE + 11;
  315. {$EXTERNALSYM SERVICE_UIC_EXEC}
  316. {*
  317. * An error occurred when attempting to run the service program.
  318. *}
  319. SERVICE_UIC_SUBSERV = SERVICE_BASE + 12;
  320. {$EXTERNALSYM SERVICE_UIC_SUBSERV}
  321. {*
  322. * The sub-service failed to start.
  323. *}
  324. SERVICE_UIC_CONFLPARM = SERVICE_BASE + 13;
  325. {$EXTERNALSYM SERVICE_UIC_CONFLPARM}
  326. {*
  327. * There is a conflict in the value or use of these options: %1.
  328. *}
  329. SERVICE_UIC_FILE = SERVICE_BASE + 14;
  330. {$EXTERNALSYM SERVICE_UIC_FILE}
  331. {*
  332. * There is a problem with the file.
  333. *}
  334. //
  335. // The modifiers
  336. //
  337. //
  338. // General:
  339. //
  340. SERVICE_UIC_M_NULL = 0;
  341. {$EXTERNALSYM SERVICE_UIC_M_NULL}
  342. //
  343. // RESOURCE:
  344. //
  345. SERVICE_UIC_M_MEMORY = SERVICE_BASE + 20; // memory
  346. {$EXTERNALSYM SERVICE_UIC_M_MEMORY}
  347. SERVICE_UIC_M_DISK = SERVICE_BASE + 21; // disk space
  348. {$EXTERNALSYM SERVICE_UIC_M_DISK}
  349. SERVICE_UIC_M_THREADS = SERVICE_BASE + 22; // thread
  350. {$EXTERNALSYM SERVICE_UIC_M_THREADS}
  351. SERVICE_UIC_M_PROCESSES = SERVICE_BASE + 23; // process
  352. {$EXTERNALSYM SERVICE_UIC_M_PROCESSES}
  353. //
  354. // CONFIG:
  355. //
  356. //
  357. // Security failure
  358. //
  359. SERVICE_UIC_M_SECURITY = SERVICE_BASE + 24;
  360. {$EXTERNALSYM SERVICE_UIC_M_SECURITY}
  361. {* Security Failure. %0 *}
  362. SERVICE_UIC_M_LANROOT = SERVICE_BASE + 25;
  363. {$EXTERNALSYM SERVICE_UIC_M_LANROOT}
  364. {*
  365. * Bad or missing LAN Manager root directory.
  366. *}
  367. SERVICE_UIC_M_REDIR = SERVICE_BASE + 26;
  368. {$EXTERNALSYM SERVICE_UIC_M_REDIR}
  369. {*
  370. * The network software is not installed.
  371. *}
  372. SERVICE_UIC_M_SERVER = SERVICE_BASE + 27;
  373. {$EXTERNALSYM SERVICE_UIC_M_SERVER}
  374. {*
  375. * The server is not started.
  376. *}
  377. SERVICE_UIC_M_SEC_FILE_ERR = SERVICE_BASE + 28;
  378. {$EXTERNALSYM SERVICE_UIC_M_SEC_FILE_ERR}
  379. {*
  380. * The server cannot access the user accounts database (NET.ACC).
  381. *}
  382. SERVICE_UIC_M_FILES = SERVICE_BASE + 29;
  383. {$EXTERNALSYM SERVICE_UIC_M_FILES}
  384. {*
  385. * Incompatible files are installed in the LANMAN tree.
  386. *}
  387. SERVICE_UIC_M_LOGS = SERVICE_BASE + 30;
  388. {$EXTERNALSYM SERVICE_UIC_M_LOGS}
  389. {*
  390. * The LANMAN\LOGS directory is invalid.
  391. *}
  392. SERVICE_UIC_M_LANGROUP = SERVICE_BASE + 31;
  393. {$EXTERNALSYM SERVICE_UIC_M_LANGROUP}
  394. {*
  395. * The domain specified could not be used.
  396. *}
  397. SERVICE_UIC_M_MSGNAME = SERVICE_BASE + 32;
  398. {$EXTERNALSYM SERVICE_UIC_M_MSGNAME}
  399. {*
  400. * The computer name is being used as a message alias on another computer.
  401. *}
  402. SERVICE_UIC_M_ANNOUNCE = SERVICE_BASE + 33;
  403. {$EXTERNALSYM SERVICE_UIC_M_ANNOUNCE}
  404. {*
  405. * The announcement of the server name failed.
  406. *}
  407. SERVICE_UIC_M_UAS = SERVICE_BASE + 34;
  408. {$EXTERNALSYM SERVICE_UIC_M_UAS}
  409. {*
  410. * The user accounts database is not configured correctly.
  411. *}
  412. SERVICE_UIC_M_SERVER_SEC_ERR = SERVICE_BASE + 35;
  413. {$EXTERNALSYM SERVICE_UIC_M_SERVER_SEC_ERR}
  414. {*
  415. * The server is not running with user-level security.
  416. *}
  417. SERVICE_UIC_M_WKSTA = SERVICE_BASE + 37;
  418. {$EXTERNALSYM SERVICE_UIC_M_WKSTA}
  419. {*
  420. * The workstation is not configured properly.
  421. *}
  422. SERVICE_UIC_M_ERRLOG = SERVICE_BASE + 38;
  423. {$EXTERNALSYM SERVICE_UIC_M_ERRLOG}
  424. {*
  425. * View your error log for details.
  426. *}
  427. SERVICE_UIC_M_FILE_UW = SERVICE_BASE + 39;
  428. {$EXTERNALSYM SERVICE_UIC_M_FILE_UW}
  429. {*
  430. * Unable to write to this file.
  431. *}
  432. SERVICE_UIC_M_ADDPAK = SERVICE_BASE + 40;
  433. {$EXTERNALSYM SERVICE_UIC_M_ADDPAK}
  434. {*
  435. * ADDPAK file is corrupted. Delete LANMAN\NETPROG\ADDPAK.SER
  436. * and reapply all ADDPAKs.
  437. *}
  438. SERVICE_UIC_M_LAZY = SERVICE_BASE + 41;
  439. {$EXTERNALSYM SERVICE_UIC_M_LAZY}
  440. {*
  441. * The LM386 server cannot be started because CACHE.EXE is not running.
  442. *}
  443. SERVICE_UIC_M_UAS_MACHINE_ACCT = SERVICE_BASE + 42;
  444. {$EXTERNALSYM SERVICE_UIC_M_UAS_MACHINE_ACCT}
  445. {*
  446. * There is no account for this computer in the security database.
  447. *}
  448. SERVICE_UIC_M_UAS_SERVERS_NMEMB = SERVICE_BASE + 43;
  449. {$EXTERNALSYM SERVICE_UIC_M_UAS_SERVERS_NMEMB}
  450. {*
  451. * This computer is not a member of the group SERVERS.
  452. *}
  453. SERVICE_UIC_M_UAS_SERVERS_NOGRP = SERVICE_BASE + 44;
  454. {$EXTERNALSYM SERVICE_UIC_M_UAS_SERVERS_NOGRP}
  455. {*
  456. * The group SERVERS is not present in the local security database.
  457. *}
  458. SERVICE_UIC_M_UAS_INVALID_ROLE = SERVICE_BASE + 45;
  459. {$EXTERNALSYM SERVICE_UIC_M_UAS_INVALID_ROLE}
  460. {*
  461. * This computer is configured as a member of a workgroup, not as
  462. * a member of a domain. The Netlogon service does not need to run in this
  463. * configuration.
  464. *}
  465. SERVICE_UIC_M_NETLOGON_NO_DC = SERVICE_BASE + 46;
  466. {$EXTERNALSYM SERVICE_UIC_M_NETLOGON_NO_DC}
  467. {*
  468. * The primary Domain Controller for this domain could not be located.
  469. *}
  470. SERVICE_UIC_M_NETLOGON_DC_CFLCT = SERVICE_BASE + 47;
  471. {$EXTERNALSYM SERVICE_UIC_M_NETLOGON_DC_CFLCT}
  472. {*
  473. * This computer is configured to be the primary domain controller of its domain.
  474. * However, the computer %1 is currently claiming to be the primary domain controller
  475. * of the domain.
  476. *}
  477. SERVICE_UIC_M_NETLOGON_AUTH = SERVICE_BASE + 48;
  478. {$EXTERNALSYM SERVICE_UIC_M_NETLOGON_AUTH}
  479. {*
  480. * The service failed to authenticate with the primary domain controller.
  481. *}
  482. SERVICE_UIC_M_UAS_PROLOG = SERVICE_BASE + 49;
  483. {$EXTERNALSYM SERVICE_UIC_M_UAS_PROLOG}
  484. {*
  485. * There is a problem with the security database creation date or serial number.
  486. *}
  487. SERVICE2_BASE = 5600;
  488. {$EXTERNALSYM SERVICE2_BASE}
  489. {* new SEVICE_UIC messages go here *}
  490. SERVICE_UIC_M_NETLOGON_MPATH = SERVICE2_BASE + 0;
  491. {$EXTERNALSYM SERVICE_UIC_M_NETLOGON_MPATH}
  492. {*
  493. * Could not share the User or Script path.
  494. *}
  495. SERVICE_UIC_M_LSA_MACHINE_ACCT = SERVICE2_BASE + 1;
  496. {$EXTERNALSYM SERVICE_UIC_M_LSA_MACHINE_ACCT}
  497. {*
  498. * The password for this computer is not found in the local security
  499. * database.
  500. *}
  501. SERVICE_UIC_M_DATABASE_ERROR = SERVICE2_BASE + 2;
  502. {$EXTERNALSYM SERVICE_UIC_M_DATABASE_ERROR}
  503. {*
  504. * An internal error occurred while accessing the computer's
  505. * local or network security database.
  506. *}
  507. //
  508. // End modifiers
  509. //
  510. //
  511. // Commonly used Macros:
  512. //
  513. function SERVICE_IP_CODE(tt, nn: LONG): LONG;
  514. {$EXTERNALSYM SERVICE_IP_CODE}
  515. function SERVICE_CCP_CODE(tt, nn: LONG): LONG;
  516. {$EXTERNALSYM SERVICE_CCP_CODE}
  517. function SERVICE_UIC_CODE(cc, mm: LONG): LONG;
  518. {$EXTERNALSYM SERVICE_UIC_CODE}
  519. //
  520. // This macro takes a wait hint (tt) which can have a maximum value of
  521. // 0xFFFF and puts it into the service status code field.
  522. // 0x0FF1FFnn (where nn is the checkpoint information).
  523. //
  524. function SERVICE_NT_CCP_CODE(tt, nn: LONG): LONG;
  525. {$EXTERNALSYM SERVICE_NT_CCP_CODE}
  526. //
  527. // This macro takes a status code field, and strips out the wait hint
  528. // from the upper and lower sections.
  529. // 0x0FF1FFnn results in 0x0000FFFF.
  530. //
  531. function SERVICE_NT_WAIT_GET(code: DWORD): DWORD;
  532. {$EXTERNALSYM SERVICE_NT_WAIT_GET}
  533. implementation
  534. // #define SERVICE_IP_CODE(tt,nn) ((long)SERVICE_IP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  535. function SERVICE_IP_CODE(tt, nn: LONG): LONG;
  536. begin
  537. Result := SERVICE_IP_QUERY_HINT or (nn or (tt shl SERVICE_IP_WAITTIME_SHIFT));
  538. end;
  539. // #define SERVICE_CCP_CODE(tt,nn) ((long)SERVICE_CCP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  540. function SERVICE_CCP_CODE(tt, nn: LONG): LONG;
  541. begin
  542. Result := SERVICE_CCP_QUERY_HINT or (nn or (tt shl SERVICE_IP_WAITTIME_SHIFT));
  543. end;
  544. // #define SERVICE_UIC_CODE(cc,mm) ((long)(((long)cc<<16)|(long)(unsigned short)mm))
  545. function SERVICE_UIC_CODE(cc, mm: LONG): LONG;
  546. begin
  547. Result := (cc shl 16) or WORD(mm);
  548. end;
  549. // #define SERVICE_NT_CCP_CODE(tt,nn) \
  550. // ( \
  551. // ((long)SERVICE_CCP_QUERY_HINT) | \
  552. // ((long)(nn)) | \
  553. // (((tt)&LOWER_HINT_MASK) << SERVICE_IP_WAITTIME_SHIFT) | \
  554. // (((tt)&UPPER_HINT_MASK) << SERVICE_NTIP_WAITTIME_SHIFT) \
  555. // )
  556. function SERVICE_NT_CCP_CODE(tt, nn: Longint): Longint;
  557. begin
  558. Result := SERVICE_CCP_QUERY_HINT or nn or ((tt and LOWER_HINT_MASK) shl SERVICE_IP_WAITTIME_SHIFT) or ((tt and UPPER_HINT_MASK) shl SERVICE_NTIP_WAITTIME_SHIFT);
  559. end;
  560. // #define SERVICE_NT_WAIT_GET(code) \
  561. // ( \
  562. // (((code) & UPPER_GET_HINT_MASK) >> SERVICE_NTIP_WAITTIME_SHIFT) | \
  563. // (((code) & LOWER_GET_HINT_MASK) >> SERVICE_IP_WAITTIME_SHIFT) \
  564. // )
  565. function SERVICE_NT_WAIT_GET(code: DWORD): DWORD;
  566. begin
  567. Result := ((code and UPPER_GET_HINT_MASK) shr SERVICE_NTIP_WAITTIME_SHIFT) or ((code and LOWER_GET_HINT_MASK) shr SERVICE_IP_WAITTIME_SHIFT);
  568. end;
  569. {$IFDEF DYNAMIC_LINK}
  570. var
  571. _NetServiceControl: Pointer;
  572. function NetServiceControl;
  573. begin
  574. GetProcedureAddress(_NetServiceControl, netapi32, 'NetServiceControl');
  575. asm
  576. MOV ESP, EBP
  577. POP EBP
  578. JMP [_NetServiceControl]
  579. end;
  580. end;
  581. var
  582. _NetServiceEnum: Pointer;
  583. function NetServiceEnum;
  584. begin
  585. GetProcedureAddress(_NetServiceEnum, netapi32, 'NetServiceEnum');
  586. asm
  587. MOV ESP, EBP
  588. POP EBP
  589. JMP [_NetServiceEnum]
  590. end;
  591. end;
  592. var
  593. _NetServiceGetInfo: Pointer;
  594. function NetServiceGetInfo;
  595. begin
  596. GetProcedureAddress(_NetServiceGetInfo, netapi32, 'NetServiceGetInfo');
  597. asm
  598. MOV ESP, EBP
  599. POP EBP
  600. JMP [_NetServiceGetInfo]
  601. end;
  602. end;
  603. var
  604. _NetServiceInstall: Pointer;
  605. function NetServiceInstall;
  606. begin
  607. GetProcedureAddress(_NetServiceInstall, netapi32, 'NetServiceInstall');
  608. asm
  609. MOV ESP, EBP
  610. POP EBP
  611. JMP [_NetServiceInstall]
  612. end;
  613. end;
  614. {$ELSE}
  615. function NetServiceControl; external netapi32 name 'NetServiceControl';
  616. function NetServiceEnum; external netapi32 name 'NetServiceEnum';
  617. function NetServiceGetInfo; external netapi32 name 'NetServiceGetInfo';
  618. function NetServiceInstall; external netapi32 name 'NetServiceInstall';
  619. {$ENDIF DYNAMIC_LINK}
  620. end.