home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 May / PCFMay2001.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / lmsvc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  13.3 KB  |  541 lines

  1. /*++ BUILD Version: 0002    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1991-1999  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     lmsvc.h
  8.  
  9. Abstract:
  10.  
  11.     This file contains structures, function prototypes, and definitions
  12.     for the NetService API.
  13.  
  14. [Environment:]
  15.  
  16.     User Mode -Win32
  17.  
  18. [Notes:]
  19.  
  20.     You must include NETCONS.H before this file, since this file depends
  21.     on values defined in NETCONS.H.
  22.  
  23. --*/
  24.  
  25. #ifndef _LMSVC_
  26. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  27. #define _LMSVC_
  28.  
  29. #if _MSC_VER > 1000
  30. #pragma once
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. //
  38. // Include the file which contains all the service name strings.
  39. //
  40. #include <lmsname.h>
  41.  
  42. //
  43. //  Data Structures
  44. //
  45.  
  46. typedef struct _SERVICE_INFO_0 {
  47.     LPWSTR  svci0_name;
  48. } SERVICE_INFO_0, *PSERVICE_INFO_0, * LPSERVICE_INFO_0;
  49.  
  50. typedef struct _SERVICE_INFO_1 {
  51.     LPWSTR  svci1_name;
  52.     DWORD   svci1_status;
  53.     DWORD   svci1_code;
  54.     DWORD   svci1_pid;
  55. } SERVICE_INFO_1, *PSERVICE_INFO_1, * LPSERVICE_INFO_1;
  56.  
  57. typedef struct _SERVICE_INFO_2 {
  58.     LPWSTR  svci2_name;
  59.     DWORD   svci2_status;
  60.     DWORD   svci2_code;
  61.     DWORD   svci2_pid;
  62.     LPWSTR  svci2_text;
  63.     DWORD   svci2_specific_error;
  64.     LPWSTR  svci2_display_name;
  65. } SERVICE_INFO_2, *PSERVICE_INFO_2, * LPSERVICE_INFO_2;
  66.  
  67. //
  68. // Function Prototypes
  69. //
  70.  
  71. NET_API_STATUS NET_API_FUNCTION
  72. NetServiceControl (
  73.     IN  LPCWSTR servername OPTIONAL,
  74.     IN  LPCWSTR service,
  75.     IN  DWORD   opcode,
  76.     IN  DWORD   arg,
  77.     OUT LPBYTE  *bufptr
  78.     );
  79.  
  80. NET_API_STATUS NET_API_FUNCTION
  81. NetServiceEnum (
  82.     IN  LPCWSTR     servername OPTIONAL,
  83.     IN  DWORD       level,
  84.     OUT LPBYTE      *bufptr,
  85.     IN  DWORD       prefmaxlen,
  86.     OUT LPDWORD     entriesread,
  87.     OUT LPDWORD     totalentries,
  88.     IN OUT LPDWORD  resume_handle OPTIONAL
  89.     );
  90.  
  91. NET_API_STATUS NET_API_FUNCTION
  92. NetServiceGetInfo (
  93.     IN  LPCWSTR servername OPTIONAL,
  94.     IN  LPCWSTR service,
  95.     IN  DWORD   level,
  96.     OUT LPBYTE   *bufptr
  97.     );
  98.  
  99. NET_API_STATUS NET_API_FUNCTION
  100. NetServiceInstall (
  101.     IN  LPCWSTR servername OPTIONAL,
  102.     IN  LPCWSTR service,
  103.     IN  DWORD   argc,
  104.     IN  LPCWSTR argv[],
  105.     OUT LPBYTE  *bufptr
  106.     );
  107.  
  108. //
  109. // Special Values and Constants
  110. //
  111.  
  112. //
  113. //  Bitmask and bit values for svci1_status, and svci2_status
  114. //  fields.  For each "subfield", there is a mask defined,
  115. //  and a number of constants representing the value
  116. //  obtained by doing (status & mask).
  117. //
  118.  
  119. // Bits 0,1 -- general status
  120.  
  121. #define SERVICE_INSTALL_STATE       0x03
  122. #define SERVICE_UNINSTALLED         0x00
  123. #define SERVICE_INSTALL_PENDING     0x01
  124. #define SERVICE_UNINSTALL_PENDING   0x02
  125. #define SERVICE_INSTALLED           0x03
  126.  
  127. // Bits 2,3 -- paused/active status
  128.  
  129. #define SERVICE_PAUSE_STATE              0x0C
  130. #define LM20_SERVICE_ACTIVE              0x00
  131. #define LM20_SERVICE_CONTINUE_PENDING    0x04
  132. #define LM20_SERVICE_PAUSE_PENDING       0x08
  133. #define LM20_SERVICE_PAUSED              0x0C
  134.  
  135. // Bit 4 -- uninstallable indication
  136.  
  137. #define SERVICE_NOT_UNINSTALLABLE   0x00
  138. #define SERVICE_UNINSTALLABLE       0x10
  139.  
  140. // Bit 5 -- pausable indication
  141.  
  142. #define SERVICE_NOT_PAUSABLE        0x00
  143. #define SERVICE_PAUSABLE            0x20
  144.  
  145. // Workstation service only:
  146. // Bits 8,9,10 -- redirection paused/active
  147.  
  148. #define SERVICE_REDIR_PAUSED        0x700
  149. #define SERVICE_REDIR_DISK_PAUSED   0x100
  150. #define SERVICE_REDIR_PRINT_PAUSED  0x200
  151. #define SERVICE_REDIR_COMM_PAUSED   0x400
  152.  
  153. //
  154. //  Additional standard LAN Manager for MS-DOS services
  155. //
  156.  
  157. #define SERVICE_DOS_ENCRYPTION  L"ENCRYPT"
  158.  
  159. //
  160. //  NetServiceControl opcodes.
  161. //
  162.  
  163. #define SERVICE_CTRL_INTERROGATE    0
  164. #define SERVICE_CTRL_PAUSE          1
  165. #define SERVICE_CTRL_CONTINUE       2
  166. #define SERVICE_CTRL_UNINSTALL      3
  167.  
  168. //
  169. //  Workstation service only:  Bits used in the "arg" parameter
  170. //  to NetServiceControl in conjunction with the opcode
  171. //  SERVICE_CTRL_PAUSE or SERVICE_CTRL_CONTINUE, to pause or
  172. //  continue redirection.
  173. //
  174.  
  175. #define SERVICE_CTRL_REDIR_DISK     0x1
  176. #define SERVICE_CTRL_REDIR_PRINT    0x2
  177. #define SERVICE_CTRL_REDIR_COMM     0x4
  178.  
  179. //
  180. //  Values for svci1_code, and svci2_code when status
  181. //  of the service is SERVICE_INSTALL_PENDING or
  182. //  SERVICE_UNINSTALL_PENDING.
  183. //  A service can optionally provide a hint to the installer
  184. //  that the install is proceeding and how long to wait
  185. //  (in 0.1 second increments) before querying status again.
  186. //
  187.  
  188. #define SERVICE_IP_NO_HINT          0x0
  189. #define SERVICE_CCP_NO_HINT         0x0
  190.  
  191. #define SERVICE_IP_QUERY_HINT       0x10000
  192. #define SERVICE_CCP_QUERY_HINT      0x10000
  193.  
  194. //
  195. // Mask for install proceeding checkpoint number
  196. //
  197.  
  198. #define SERVICE_IP_CHKPT_NUM        0x0FF
  199. #define SERVICE_CCP_CHKPT_NUM       0x0FF
  200.  
  201. //
  202. // Mask for wait time hint before querying again
  203. //
  204.  
  205. #define SERVICE_IP_WAIT_TIME        0x0FF00
  206. #define SERVICE_CCP_WAIT_TIME       0x0FF00
  207.  
  208. //
  209. // Shift count for building wait time _code values
  210. //
  211.  
  212. #define SERVICE_IP_WAITTIME_SHIFT   8
  213. #define SERVICE_NTIP_WAITTIME_SHIFT 12
  214.  
  215. //
  216. // Mask used for upper and lower portions of wait hint time.
  217. //
  218. #define UPPER_HINT_MASK     0x0000FF00
  219. #define LOWER_HINT_MASK     0x000000FF
  220. #define UPPER_GET_HINT_MASK 0x0FF00000
  221. #define LOWER_GET_HINT_MASK 0x0000FF00
  222. #define SERVICE_NT_MAXTIME  0x0000FFFF
  223. #define SERVICE_RESRV_MASK  0x0001FFFF
  224. #define SERVICE_MAXTIME     0x000000FF
  225.  
  226. //
  227. //  SERVICE_BASE is the base of service error codes,
  228. //  chosen to avoid conflict with OS, redirector,
  229. //  netapi, and errlog codes.
  230. //
  231. // Don't change the comments following the manifest constants without
  232. // understanding how mapmsg works.
  233. //
  234.  
  235. #define SERVICE_BASE                3050
  236. #define SERVICE_UIC_NORMAL          0
  237. /*
  238.  *  Uninstall codes, to be used in high byte of 'code' on final NetStatus,
  239.  *  which sets the status to UNINSTALLED.
  240.  */
  241.  
  242. #define SERVICE_UIC_BADPARMVAL          (SERVICE_BASE + 1)
  243. /*
  244.  * The Registry or the information you just typed includes an illegal
  245.  * value for "%1".
  246.  */
  247.  
  248. #define SERVICE_UIC_MISSPARM            (SERVICE_BASE + 2)
  249. /*
  250.  * The required parameter was not provided on the command
  251.  * line or in the configuration file.
  252.  */
  253.  
  254. #define SERVICE_UIC_UNKPARM             (SERVICE_BASE + 3)
  255. /*
  256.  * LAN Manager does not recognize "%1" as a valid option.
  257.  */
  258.  
  259. #define SERVICE_UIC_RESOURCE            (SERVICE_BASE + 4)
  260. /*
  261.  * A request for resource could not be satisfied.
  262.  */
  263.  
  264. #define SERVICE_UIC_CONFIG              (SERVICE_BASE + 5)
  265. /*
  266.  * A problem exists with the system configuration.
  267.  */
  268.  
  269. #define SERVICE_UIC_SYSTEM              (SERVICE_BASE + 6)
  270. /*
  271.  * A system error has occurred.
  272.  */
  273.  
  274. #define SERVICE_UIC_INTERNAL            (SERVICE_BASE + 7)
  275. /*
  276.  * An internal consistency error has occurred.
  277.  */
  278.  
  279. #define SERVICE_UIC_AMBIGPARM           (SERVICE_BASE + 8)
  280. /*
  281.  * The configuration file or the command line has an ambiguous option.
  282.  */
  283.  
  284. #define SERVICE_UIC_DUPPARM             (SERVICE_BASE + 9)
  285. /*
  286.  * The configuration file or the command line has a duplicate parameter.
  287.  */
  288.  
  289. #define SERVICE_UIC_KILL                (SERVICE_BASE + 10)
  290. /*
  291.  * The service did not respond to control and was stopped with
  292.  * the DosKillProc function.
  293.  */
  294.  
  295. #define SERVICE_UIC_EXEC                (SERVICE_BASE + 11)
  296. /*
  297.  * An error occurred when attempting to run the service program.
  298.  */
  299.  
  300. #define SERVICE_UIC_SUBSERV             (SERVICE_BASE + 12)
  301. /*
  302.  * The sub-service failed to start.
  303.  */
  304.  
  305. #define SERVICE_UIC_CONFLPARM           (SERVICE_BASE + 13)
  306. /*
  307.  * There is a conflict in the value or use of these options: %1.
  308.  */
  309.  
  310. #define SERVICE_UIC_FILE                (SERVICE_BASE + 14)
  311. /*
  312.  * There is a problem with the file.
  313.  */
  314.  
  315.  
  316.  
  317. //
  318. //  The modifiers
  319. //
  320.  
  321. //
  322. // General:
  323. //
  324.  
  325. #define SERVICE_UIC_M_NULL  0
  326.  
  327. //
  328. //  RESOURCE:
  329. //
  330.  
  331. #define SERVICE_UIC_M_MEMORY    (SERVICE_BASE + 20)     /* memory */
  332. #define SERVICE_UIC_M_DISK      (SERVICE_BASE + 21)     /* disk space */
  333. #define SERVICE_UIC_M_THREADS   (SERVICE_BASE + 22)     /* thread */
  334. #define SERVICE_UIC_M_PROCESSES (SERVICE_BASE + 23)     /* process */
  335.  
  336. //
  337. //  CONFIG:
  338. //
  339.  
  340. //
  341. // Security failure
  342. //
  343.  
  344. #define SERVICE_UIC_M_SECURITY          (SERVICE_BASE + 24)
  345. /* Security Failure. %0 */
  346.  
  347. #define SERVICE_UIC_M_LANROOT           (SERVICE_BASE + 25)
  348. /*
  349.  * Bad or missing LAN Manager root directory.
  350.  */
  351.  
  352. #define SERVICE_UIC_M_REDIR             (SERVICE_BASE + 26)
  353. /*
  354.  * The network software is not installed.
  355.  */
  356.  
  357. #define SERVICE_UIC_M_SERVER            (SERVICE_BASE + 27)
  358. /*
  359.  * The server is not started.
  360.  */
  361.  
  362. #define SERVICE_UIC_M_SEC_FILE_ERR      (SERVICE_BASE + 28)
  363. /*
  364.  * The server cannot access the user accounts database (NET.ACC).
  365.  */
  366.  
  367. #define SERVICE_UIC_M_FILES             (SERVICE_BASE + 29)
  368. /*
  369.  * Incompatible files are installed in the LANMAN tree.
  370.  */
  371.  
  372. #define SERVICE_UIC_M_LOGS              (SERVICE_BASE + 30)
  373. /*
  374.  * The LANMAN\LOGS directory is invalid.
  375.  */
  376.  
  377. #define SERVICE_UIC_M_LANGROUP          (SERVICE_BASE + 31)
  378. /*
  379.  * The domain specified could not be used.
  380.  */
  381.  
  382. #define SERVICE_UIC_M_MSGNAME           (SERVICE_BASE + 32)
  383. /*
  384.  * The computer name is being used as a message alias on another computer.
  385.  */
  386.  
  387. #define SERVICE_UIC_M_ANNOUNCE          (SERVICE_BASE + 33)
  388. /*
  389.  * The announcement of the server name failed.
  390.  */
  391.  
  392. #define SERVICE_UIC_M_UAS               (SERVICE_BASE + 34)
  393. /*
  394.  * The user accounts database is not configured correctly.
  395.  */
  396.  
  397. #define SERVICE_UIC_M_SERVER_SEC_ERR    (SERVICE_BASE + 35)
  398. /*
  399.  * The server is not running with user-level security.
  400.  */
  401.  
  402. #define SERVICE_UIC_M_WKSTA             (SERVICE_BASE + 37)
  403. /*
  404.  * The workstation is not configured properly.
  405.  */
  406.  
  407. #define SERVICE_UIC_M_ERRLOG            (SERVICE_BASE + 38)
  408. /*
  409.  * View your error log for details.
  410.  */
  411.  
  412. #define SERVICE_UIC_M_FILE_UW           (SERVICE_BASE + 39)
  413. /*
  414.  * Unable to write to this file.
  415.  */
  416.  
  417. #define SERVICE_UIC_M_ADDPAK            (SERVICE_BASE + 40)
  418. /*
  419.  * ADDPAK file is corrupted.  Delete LANMAN\NETPROG\ADDPAK.SER
  420.  * and reapply all ADDPAKs.
  421.  */
  422.  
  423. #define SERVICE_UIC_M_LAZY              (SERVICE_BASE + 41)
  424. /*
  425.  * The LM386 server cannot be started because CACHE.EXE is not running.
  426.  */
  427.  
  428. #define SERVICE_UIC_M_UAS_MACHINE_ACCT  (SERVICE_BASE + 42)
  429. /*
  430.  * There is no account for this computer in the security database.
  431.  */
  432.  
  433. #define SERVICE_UIC_M_UAS_SERVERS_NMEMB (SERVICE_BASE + 43)
  434. /*
  435.  * This computer is not a member of the group SERVERS.
  436.  */
  437.  
  438. #define SERVICE_UIC_M_UAS_SERVERS_NOGRP (SERVICE_BASE + 44)
  439. /*
  440.  * The group SERVERS is not present in the local security database.
  441.  */
  442.  
  443. #define SERVICE_UIC_M_UAS_INVALID_ROLE  (SERVICE_BASE + 45)
  444. /*
  445.  * This Windows NT computer is configured as a member of a workgroup, not as
  446.  * a member of a domain. The Netlogon service does not need to run in this
  447.  * configuration.
  448.  */
  449.  
  450. #define SERVICE_UIC_M_NETLOGON_NO_DC    (SERVICE_BASE + 46)
  451. /*
  452.  * The Windows NT domain controller for this domain could not be located.
  453.  */
  454.  
  455. #define SERVICE_UIC_M_NETLOGON_DC_CFLCT (SERVICE_BASE + 47)
  456. /*
  457.  * This computer is configured to be the primary domain controller of its domain.
  458.  * However, the computer %1 is currently claiming to be the primary domain controller
  459.  * of the domain.
  460.  */
  461.  
  462. #define SERVICE_UIC_M_NETLOGON_AUTH     (SERVICE_BASE + 48)
  463. /*
  464.  * The service failed to authenticate with the primary domain controller.
  465.  */
  466.  
  467. #define SERVICE_UIC_M_UAS_PROLOG        (SERVICE_BASE + 49)
  468. /*
  469.  * There is a problem with the security database creation date or serial number.
  470.  */
  471.  
  472.  
  473. #define SERVICE2_BASE    5600
  474. /* new SEVICE_UIC messages go here */
  475.  
  476. #define SERVICE_UIC_M_NETLOGON_MPATH    (SERVICE2_BASE + 0)
  477. /*
  478.  * Could not share the User or Script path.
  479.  */
  480.  
  481. #define SERVICE_UIC_M_LSA_MACHINE_ACCT  (SERVICE2_BASE + 1)
  482. /*
  483.  * The password for this computer is not found in the local security
  484.  * database.
  485.  */
  486.  
  487. #define SERVICE_UIC_M_DATABASE_ERROR    (SERVICE2_BASE + 2)
  488. /*
  489.  * An internal error occurred while accessing the computer's
  490.  * local or network security database.
  491.  */
  492.  
  493.  
  494. //
  495. //  End modifiers
  496. //
  497.  
  498. //
  499. // Commonly used Macros:
  500. //
  501.  
  502. #define SERVICE_IP_CODE(tt,nn) \
  503.   ((long)SERVICE_IP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  504.  
  505. #define SERVICE_CCP_CODE(tt,nn) \
  506.   ((long)SERVICE_CCP_QUERY_HINT|(long)(nn|(tt<<SERVICE_IP_WAITTIME_SHIFT)))
  507.  
  508. #define SERVICE_UIC_CODE(cc,mm) \
  509.   ((long)(((long)cc<<16)|(long)(unsigned short)mm))
  510.  
  511. //
  512. // This macro takes a wait hint (tt) which can have a maximum value of
  513. // 0xFFFF and puts it into the service status code field.
  514. // 0x0FF1FFnn  (where nn is the checkpoint information).
  515. //
  516. #define SERVICE_NT_CCP_CODE(tt,nn)  \
  517.   (  \
  518.     ((long)SERVICE_CCP_QUERY_HINT)   | \
  519.     ((long)(nn))   | \
  520.     (((tt)&LOWER_HINT_MASK) << SERVICE_IP_WAITTIME_SHIFT)   | \
  521.     (((tt)&UPPER_HINT_MASK) << SERVICE_NTIP_WAITTIME_SHIFT)   \
  522.   )
  523.  
  524. //
  525. // This macro takes a status code field, and strips out the wait hint
  526. // from the upper and lower sections.
  527. // 0x0FF1FFnn results in 0x0000FFFF.
  528. //
  529. #define SERVICE_NT_WAIT_GET(code) \
  530.     (   \
  531.       (((code) & UPPER_GET_HINT_MASK) >> SERVICE_NTIP_WAITTIME_SHIFT)  |  \
  532.       (((code) & LOWER_GET_HINT_MASK) >> SERVICE_IP_WAITTIME_SHIFT)  \
  533.     )
  534.  
  535. #ifdef __cplusplus
  536. }
  537. #endif
  538.  
  539. #pragma option pop /*P_O_Pop*/
  540. #endif // _LMSVC_
  541.