Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

790 lines
19 KiB

  1. #include <lodctr.h>
  2. #include <unlodctr.h>
  3. extern "C"
  4. {
  5. int unlodctr( HKEY hkey, LPWSTR lpArg );
  6. int lodctr( HKEY hkey, LPWSTR lpIniFile );
  7. }
  8. /*++
  9. This function calls the service controller to create a new service.
  10. Arguments:
  11. pszServiceName pointer to service name
  12. pszDisplayName pointer to Display name
  13. pszPath pointer to null-terminated string containing the path for
  14. the service DLL.
  15. Returns:
  16. TRUE on success and FALSE if there is any failure.
  17. Use GetLastError() to get further error code on failure.
  18. --*/
  19. BOOL
  20. CreateServiceEntry( IN char * pszServiceName,
  21. IN char * pszDisplayName,
  22. IN char * pszPath);
  23. /*++
  24. This function calls the service controller to create a new service.
  25. Arguments:
  26. pszServiceName pointer to service name
  27. pszDisplayName pointer to Display name
  28. pszPath pointer to null-terminated string containing the path for
  29. the service DLL.
  30. dwServiceType type of service
  31. pszDependencies pointer to array of dependency names
  32. pszServiceStartName pointer to account name of service
  33. Returns:
  34. TRUE on success and FALSE if there is any failure.
  35. Use GetLastError() to get further error code on failure.
  36. --*/
  37. BOOL
  38. CreateServiceEntry( IN char * pszServiceName,
  39. IN char * pszDisplayName,
  40. IN char * pszPath,
  41. IN DWORD dwServiceType,
  42. IN char * pszDependencies,
  43. IN char * pszServiceStartName);
  44. /*++
  45. This function calls the service controller to create a new service.
  46. Arguments:
  47. pszServiceName pointer to service name
  48. pszDisplayName pointer to Display name
  49. pszPath pointer to null-terminated string containing the path for
  50. the service DLL.
  51. dwServiceType type of service
  52. pszDependencies pointer to array of dependency names
  53. pszServiceStartName pointer to account name of service
  54. pszPassword pointer to account password of service
  55. Returns:
  56. TRUE on success and FALSE if there is any failure.
  57. Use GetLastError() to get further error code on failure.
  58. --*/
  59. BOOL
  60. CreateServiceEntry( IN char * pszServiceName,
  61. IN char * pszDisplayName,
  62. IN char * pszPath,
  63. IN DWORD dwServiceType,
  64. IN char * pszDependencies,
  65. IN char * pszServiceStartName,
  66. IN char * pszPassword);
  67. /*++
  68. This function calls the service controller to delete a
  69. existing service.
  70. Arguments:
  71. pszServiceName pointer to service name
  72. Returns:
  73. TRUE on success and FALSE if there is any failure.
  74. Use GetLastError() to get further error code on failure.
  75. --*/
  76. BOOL
  77. DeleteServiceEntry( IN char * pszServiceName);
  78. /*++
  79. This function calls the service controller to stop a
  80. running service.
  81. Arguments:
  82. hService service handle to server to stop
  83. Returns:
  84. TRUE on success and FALSE if there is any failure.
  85. Use GetLastError() to get further error code on failure.
  86. --*/
  87. BOOL
  88. StopService( IN char * pszServiceName );
  89. /*++
  90. This function calls the service controller to check if
  91. a service is running.
  92. Arguments:
  93. lpszServiceName Name of the service to check
  94. Returns:
  95. TRUE if it is running and FALSE otherwise.
  96. --*/
  97. BOOL
  98. fIsServiceRunning(LPSTR lpszServiceName);
  99. /*++
  100. This function adds the service to the list of services that
  101. inetinfo.exe will support.
  102. Arguments:
  103. pszServiceName pointer to service name
  104. Returns:
  105. TRUE on success and FALSE if there is any failure.
  106. Use GetLastError() to get further error code on failure.
  107. Comments:
  108. Note that inetinfo.exe reads this value only at startup,
  109. therefore, inetinfo.exe must be restarted before this
  110. change will take effect.
  111. --*/
  112. BOOL
  113. AddInetinfoService(IN LPSTR pszServiceName);
  114. /*++
  115. This function removes a service from the list of services that
  116. inetinfo.exe will support.
  117. Arguments:
  118. pszServiceName pointer to service name
  119. Returns:
  120. TRUE on success and FALSE if there is any failure.
  121. Use GetLastError() to get further error code on failure.
  122. Comments:
  123. --*/
  124. BOOL
  125. RemoveInetinfoService(IN LPSTR pszServiceName);
  126. /*++
  127. This function searches for inetinfo.exe services that are
  128. running and returns a list separated by '\n' and terminated
  129. by '\n\0'.
  130. Arguments:
  131. lpSvcList pointer to buffer to receive list
  132. cbMax max size of buffer
  133. Returns:
  134. TRUE on success and FALSE if there is any failure.
  135. Use GetLastError() to get further error code on failure.
  136. --*/
  137. BOOL
  138. DetectRunningServicesEx(IN LPSTR lpSvcList,IN INT cbMax,IN LPSTR lpExtraSvcList);
  139. /*++
  140. This function searches for inetinfo.exe services that are
  141. running and returns a list separated by '\n' and terminated
  142. by '\n\0'.
  143. Arguments:
  144. lpSvcList pointer to buffer to receive list
  145. cbMax max size of buffer
  146. Returns:
  147. TRUE on success and FALSE if there is any failure.
  148. Use GetLastError() to get further error code on failure.
  149. --*/
  150. BOOL
  151. DetectRunningServices(IN LPSTR lpSvcList,IN INT cbMax);
  152. /*++
  153. This function registers or unregisters a network service.
  154. Arguments:
  155. pszMachine pointer to machine name
  156. pszServiceName pointer to service name
  157. pGuid pointer to service GUID
  158. SapId service SAP ID (use zero)
  159. TcpPort service TCP port number
  160. pszAnonPwdSecret service anonymous user secret name
  161. pszAnonPwd service anonymous user password
  162. pszRootPwdSecret service root password secret name
  163. pszRootPwd service root password
  164. fAdd TRUE - add service, FALSE - remove service
  165. fSetSecretPasswd TRUE - set passwords
  166. Returns:
  167. TRUE on success and FALSE if there is any failure.
  168. Use GetLastError() to get further error code on failure.
  169. --*/
  170. BOOL
  171. PerformSetService( IN LPSTR pszMachine,
  172. IN LPSTR pszServiceName,
  173. IN GUID * pGuid,
  174. IN DWORD SapId,
  175. IN DWORD TcpPort,
  176. IN LPWSTR pszAnonPwdSecret,
  177. IN LPWSTR pszAnonPwd,
  178. IN LPWSTR pszRootPwdSecret,
  179. IN LPWSTR pszRootPwd,
  180. IN BOOL fAdd,
  181. IN BOOL fSetSecretPasswd );
  182. /*++
  183. This function installs a SNMP agent to the registry
  184. Arguments:
  185. hKey key handle under which agent is added (HKEY_LOCAL_MACHINE)
  186. lpcName pointer to the name of the service whos agent is being installed
  187. lpcPath pointer to the path of the service extension agent DLL
  188. Returns:
  189. TRUE on success and FALSE if there is any failure.
  190. Use GetLastError() to get further error code on failure.
  191. --*/
  192. void InstallAgent( HKEY hKey, LPCSTR lpcName, LPCSTR lpcPath );
  193. /*++
  194. This function removes a SNMP agent
  195. Arguments:
  196. hKey key handle under which agent is located (HKEY_LOCAL_MACHINE)
  197. lpcName pointer to the name of the service whos agent is being removed
  198. Returns:
  199. TRUE on success and FALSE if there is any failure.
  200. Use GetLastError() to get further error code on failure.
  201. --*/
  202. void RemoveAgent( HKEY hKey, LPCSTR lpcName );
  203. /*++
  204. This function registers the service's performance dll information.
  205. This function DOES NOT load the performance counters.
  206. Arguments:
  207. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  208. lpcName pointer to the name of the service
  209. lpcDll pointer to service's performance dll
  210. lpcOpen pointer to open api name
  211. lpcClose pointer to close api name
  212. lpcCollect pointer to collect api name
  213. Returns:
  214. TRUE on success and FALSE if there is any failure.
  215. Use GetLastError() to get further error code on failure.
  216. --*/
  217. void InstallPerformance( IN HKEY hKey,
  218. IN LPCSTR lpcName,
  219. IN LPCSTR lpcDll,
  220. IN LPCSTR lpcOpen,
  221. IN LPCSTR lpcClose,
  222. IN LPCSTR lpcCollect );
  223. /*++
  224. This function removes the service's performance DLL information.
  225. Arguments:
  226. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  227. lpcName pointer to the name of the service
  228. Returns:
  229. TRUE on success and FALSE if there is any failure.
  230. Use GetLastError() to get further error code on failure.
  231. --*/
  232. void RemovePerformance( IN HKEY hKey,
  233. IN LPCSTR lpcName );
  234. /*++
  235. This function registers the service's event log information.
  236. Arguments:
  237. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  238. lpcName pointer to the name of the service
  239. lpcMsgFile pointer to service's message dll
  240. dwType types supported
  241. Returns:
  242. TRUE on success and FALSE if there is any failure.
  243. Use GetLastError() to get further error code on failure.
  244. --*/
  245. BOOL
  246. InstallEventLog(IN HKEY hKey,
  247. IN LPCSTR lpcName,
  248. IN LPCSTR lpcMsgFile,
  249. IN DWORD dwType );
  250. /*++
  251. This function registers the service's event log information.
  252. Arguments:
  253. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  254. lpcName pointer to the name of the service
  255. lpcMsgFile pointer to service's message dll
  256. dwType types supported
  257. dwLogType Type of log entry: 0="System", 1="Security", or 2="Application"
  258. Returns:
  259. TRUE on success and FALSE if there is any failure.
  260. Use GetLastError() to get further error code on failure.
  261. --*/
  262. BOOL
  263. InstallEventLog(IN HKEY hKey,
  264. IN LPCSTR lpcName,
  265. IN LPCSTR lpcMsgFile,
  266. IN DWORD dwType,
  267. IN DWORD dwLogType);
  268. /*++
  269. This function removes the service's event log information.
  270. Arguments:
  271. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  272. lpcName pointer to the name of the service
  273. Returns:
  274. TRUE on success and FALSE if there is any failure.
  275. Use GetLastError() to get further error code on failure.
  276. --*/
  277. void
  278. RemoveEventLog( IN HKEY hKey,
  279. IN LPCSTR lpcName );
  280. /*++
  281. This function removes the service's event log information.
  282. Arguments:
  283. hKey key handle, use HKEY_LOCAL_MACHINE for local machine
  284. lpcName pointer to the name of the service
  285. dwLogType Type of log entry: 0="System", 1="Security", or 2="Application"
  286. Returns:
  287. TRUE on success and FALSE if there is any failure.
  288. Use GetLastError() to get further error code on failure.
  289. --*/
  290. void RemoveEventLog( HKEY hKey, LPCSTR lpcName, DWORD dwLogType );
  291. /*++
  292. This function retrieves the install path for IIS 2.0
  293. Arguments:
  294. lpszPath pointer to buffer to receive path
  295. cbMax max size of buffer including null terminator
  296. Returns:
  297. TRUE on success and FALSE if there is any failure.
  298. Use GetLastError() to get further error code on failure.
  299. Comments:
  300. To be used from an InstallShield3 script, this function
  301. must be wrapped in a exported function that uses the C
  302. calling convention.
  303. For example:
  304. extern "C" INT GetIISInstallPath(LPSTR lpszPath,INT cbMax)
  305. {
  306. return libGetIISInstallPath(lpszPath,cbMax);
  307. }
  308. --*/
  309. INT libGetIISInstallPath(LPSTR lpszPath,INT cbMax);
  310. /*++
  311. This function retrieves the version info for the OS.
  312. Arguments:
  313. lpnPlatformId pointer to buffer to receive the PlateformId
  314. lpnMajor pointer to buffer to receive the Major version number
  315. lpnMinor pointer to buffer to receive the Minor version number
  316. lpnBuild pointer to buffer to receive the Build number
  317. lpnServicePack pointer to buffer to receive the service pack number
  318. Returns:
  319. TRUE on success and FALSE if there is any failure.
  320. Use GetLastError() to get further error code on failure.
  321. Comments:
  322. To be used from an InstallShield3 script, this function
  323. must be wrapped in a exported function that uses the C
  324. calling convention.
  325. For example:
  326. extern "C" INT GetOSVersionInfo(INT *lpnPlatformId,
  327. INT *lpnBuild,
  328. INT *lpnServicePack)
  329. {
  330. return libGetOSVersionInfo(lpnPlatformId,
  331. lpnBuild,
  332. lpnServicePack);
  333. }
  334. See also: GetVersionEx, OSVERSIONINFO
  335. --*/
  336. INT
  337. libGetOSVersionInfoEx(INT *lpnPlatformId,
  338. INT *lpnMajor,
  339. INT *lpnMinor,
  340. INT *lpnBuild,
  341. INT *lpnServicePack);
  342. /*++
  343. Same as above but without nMajor and nMinor.
  344. --*/
  345. INT
  346. libGetOSVersionInfo(INT *lpnPlatformId,
  347. INT *lpnBuild,
  348. INT *lpnServicePack);
  349. /*++
  350. This function gets the anonymous user and password used
  351. by the installed IIS services.
  352. Arguments:
  353. lpszUser pointer to buffer to receive user name
  354. lpszPass pointer to buffer to receive password
  355. Returns:
  356. TRUE on success and FALSE if there is any failure.
  357. Use GetLastError() to get further error code on failure.
  358. --*/
  359. BOOL
  360. GetAnonymousUserPass(IN LPSTR lpszUser,
  361. IN LPSTR lpszPass);
  362. /*++
  363. This function sets the anonymous user for a service.
  364. Arguments:
  365. lpszSvc pointer to service name
  366. lpszUser pointer to user name
  367. Returns:
  368. TRUE on success and FALSE if there is any failure.
  369. Use GetLastError() to get further error code on failure.
  370. --*/
  371. BOOL
  372. SetAnonymousUser(IN LPSTR lpszSvc,
  373. IN LPSTR lpszUser);
  374. //
  375. // Handy reg utility functions
  376. //
  377. LONG RegSetSZ(HKEY hKey,LPSTR lpszName,LPSTR lpszValue);
  378. LONG RegSetDWORD(HKEY hKey,LPSTR lpszName,DWORD dwValue);
  379. LONG RegSetMULTI_SZ(HKEY hKey, LPSTR szName, LPSTR szValue);
  380. // same as RegDeleteKey except will delete all subkeys
  381. LONG RegDeleteTree(HKEY hKey, LPCSTR lpszKeyName);
  382. //+---------------------------------------------------------------------------
  383. //
  384. // Function: AppendRegKey
  385. //
  386. // Synopsis: Append a value to a comma-separated registry key string
  387. //
  388. // Arguments: [szRegKey]
  389. // [szRegSubkey]
  390. // [szRegValue]
  391. //
  392. // Returns: TRUE for success, FALSE for failure
  393. //
  394. // History: 11/19/95 RobLeit Created
  395. //
  396. //----------------------------------------------------------------------------
  397. BOOL AppendRegKey(char *szRegKey, char *szRegSubkey, char *szRegValue);
  398. //+---------------------------------------------------------------------------
  399. //
  400. // Function: UnAppendRegKey
  401. //
  402. // Synopsis: Remove the value from the comma separated string,
  403. // if it is there (undo AppendRegKey)
  404. //
  405. // Arguments: [szRegKey]
  406. // [szRegSubkey]
  407. // [szRegValue]
  408. //
  409. // Returns: TRUE for success, FALSE for failure
  410. //
  411. // History: 11/27/95 RobLeit Created
  412. //
  413. // Notes:
  414. //
  415. //----------------------------------------------------------------------------
  416. BOOL UnAppendRegKey(char *szRegKey, char *szRegSubkey, char *szRegValue);
  417. //+----------------------------------------------------------------------
  418. //
  419. // Function: IsDomainController
  420. //
  421. // Synopsis: This function checks if local machine is a
  422. // primary or backup domain controller (PDC or BDC)
  423. //
  424. // Arguments: None
  425. //
  426. // Returns: BOOL - TRUE is it is a DC
  427. //
  428. // History: RobLeit Created 1/25/96
  429. //
  430. //-----------------------------------------------------------------------
  431. BOOL
  432. IsDomainController();
  433. //+----------------------------------------------------------------------
  434. //
  435. // Function: GetDomainName
  436. //
  437. // Synopsis: This function gets the domain name for the local
  438. // machine.
  439. //
  440. // Arguments: strDomain - where to store the domain
  441. // pcchDomain - IN: size of strDomain array
  442. // OUT: length of strDomain string
  443. //
  444. // Returns: void
  445. //
  446. // Comments: From KB, PSS ID Number: Q111544
  447. //
  448. // History: RobLeit Created 1/25/96
  449. //
  450. //-----------------------------------------------------------------------
  451. void
  452. GetDomainName(LPSTR strDomain,LPDWORD pcchDomain);
  453. //+----------------------------------------------------------------------
  454. // BOOL IsAdmin(void)
  455. //
  456. // returns TRUE if user is an admin
  457. // FALSE if user is not an admin
  458. //
  459. // PSS ID Number: Q118626
  460. //+----------------------------------------------------------------------
  461. BOOL IsAdmin(void);
  462. //+----------------------------------------------------------------------
  463. //
  464. // Function: CheckAccount
  465. //
  466. // Synopsis: This function checks that the account exists in the given
  467. // domain.
  468. //
  469. // Arguments: szUsername - User name
  470. // szDomain - Domain: may be NULL for local domain
  471. //
  472. // Returns: BOOL
  473. //
  474. // History: RobLeit Created 1/25/96
  475. //
  476. //-----------------------------------------------------------------------
  477. BOOL CheckAccount(char *szUsername,
  478. char *szDomain);
  479. //+----------------------------------------------------------------------
  480. //
  481. // Function: CreateGuestAccount
  482. //
  483. // Synopsis: This function creates an account in the given domain,
  484. // with privileges equivalent to guest
  485. //
  486. // Arguments: szUsername - User name
  487. // szFullName - Full name of user
  488. // szComment - Account comment
  489. // szDomain - Domain: may be NULL for local domain
  490. // szPassword - Account password
  491. //
  492. // Returns: BOOL
  493. //
  494. // History: RobLeit Created 1/25/96
  495. //
  496. //-----------------------------------------------------------------------
  497. BOOL CreateGuestAccount(char *szUsername,
  498. char *szFullName,
  499. char *szComment,
  500. char *szDomain,
  501. char *szPassword);
  502. /*++
  503. Description
  504. Sets the specified LSA secret
  505. Arguments:
  506. Server - Server name (or NULL) secret lives on
  507. SecretName - Name of the LSA secret
  508. pSecret - Pointer to secret memory
  509. cbSecret - Size of pSecret memory block
  510. Note:
  511. --*/
  512. DWORD
  513. SetSecret( IN LPWSTR Server,
  514. IN LPWSTR SecretName,
  515. IN LPWSTR pSecret,
  516. IN DWORD cbSecret);
  517. /*++
  518. Description:
  519. Retrieves the specified unicode secret
  520. Arguments:
  521. szAnsiName - Name of LSA Secret to retrieve
  522. szAnsiSecret - Receives found secret
  523. Returns:
  524. TRUE on success and FALSE if any failure.
  525. --*/
  526. BOOL
  527. GetSecret( IN LPCSTR szAnsiName,
  528. OUT LPSTR szAnsiSecret );
  529. /*++
  530. This function calls the service controller to start
  531. a service.
  532. Arguments:
  533. pszServiceName pointer to service name
  534. Returns:
  535. TRUE on success and FALSE if there is any failure.
  536. Use GetLastError() to get further error code on failure.
  537. --*/
  538. BOOL
  539. libStartService(IN char * pszServiceName);
  540. /*
  541. * Checks to see if a service is installed
  542. */
  543. BOOL
  544. libIsServiceInstalled(LPSTR lpszServiceName);
  545. /*++
  546. This function determines if NT Server or NT Advance service is running.
  547. Arguments:
  548. Returns:
  549. TRUE if server is running NT server or NT advanced server and
  550. FALSE otherwise.
  551. Comments:
  552. --*/
  553. BOOL
  554. libIsNTServer(void);
  555. /*
  556. * Adds reg entry for service ism dll
  557. */
  558. BOOL
  559. AddInetMgrAddOn(LPSTR lpszServiceName, LPSTR lpszDllName);
  560. /*
  561. * Removes reg entry for service ism dll
  562. */
  563. BOOL
  564. RemoveInetMgrAddOn(LPSTR lpszServiceName);
  565. /*
  566. * Adds reg entry for service key ring dll
  567. */
  568. BOOL
  569. AddKeyRingAddOn(LPSTR lpszServiceName, LPSTR lpszDllName);
  570. /*
  571. * Removes reg entry for service key ring dll
  572. */
  573. BOOL
  574. RemoveKeyRingAddOn(LPSTR lpszServiceName);
  575. /*
  576. * check if the filesystem is an NTFS volume
  577. */
  578. extern "C" BOOL libCheckNTFS( LPCTSTR ptstrFileSystemRoot );
  579. /*
  580. * check if the filesystem has the capability to store acl's
  581. */
  582. extern "C" BOOL libCheckFilesystemSupportsAcls( LPCTSTR ptstrFileSystemRoot );
  583. /*
  584. * check if the drive is a fixed hard drive on the local system
  585. */
  586. extern "C" BOOL libCheckIsLocalFixedDrive( LPCTSTR ptstrFileSystemRoot );
  587. /*
  588. * Installs Jnet reg keys and perfmon counters. Requires the full path dir
  589. * containing the jnfoctrs.ini and jfoctrs.h files.
  590. */
  591. BOOL libInstallJnfoComm(LPSTR lpszDstDir, LPSTR lpszIniDir);
  592. /*
  593. * Removes Jnet reg keys and perfmon counters when reference count on
  594. * jnfocomm.dll reaches 1 or zero. It is assumed that this call is made
  595. * before the file is actually deleted and the reference count reaches zero.
  596. */
  597. void libRemoveJnfoComm(void);