Leaked source code of windows server 2003
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.

2516 lines
85 KiB

  1. ;begin_both
  2. //=============================================================================
  3. // userenv.h - Header file for user environment API.
  4. // User Profiles, environment variables, and Group Policy
  5. //
  6. // Copyright (c) Microsoft Corporation 1995-2002
  7. // All rights reserved
  8. //
  9. //=============================================================================
  10. ;end_both
  11. #ifndef _INC_USERENV
  12. #define _INC_USERENV
  13. #ifndef _INC_USERENVP ;internal
  14. #define _INC_USERENVP ;internal
  15. #include <wbemcli.h>
  16. #include <profinfo.h>
  17. //
  18. // Define API decoration for direct importing of DLL references.
  19. //
  20. #if !defined(_USERENV_)
  21. #define USERENVAPI DECLSPEC_IMPORT
  22. #else
  23. #define USERENVAPI
  24. #endif
  25. ;begin_both
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. ;end_both
  30. //=============================================================================
  31. //
  32. // LoadUserProfile
  33. //
  34. // Loads the specified user's profile.
  35. //
  36. // Most applications should not need to use this function. It's used
  37. // when a user has logged onto the system or a service starts in a named
  38. // user account.
  39. //
  40. // hToken - Token for the user, returned from LogonUser()
  41. // lpProfileInfo - Address of a PROFILEINFO structure
  42. //
  43. // Returns: TRUE if successful
  44. // FALSE if not. Call GetLastError() for more details
  45. //
  46. // Note: The caller of this function must have admin privileges on the machine.
  47. //
  48. // Upon successful return, the hProfile member of the PROFILEINFO
  49. // structure is a registry key handle opened to the root
  50. // of the user's hive. It has been opened with full access. If
  51. // you need to read or write to the user's registry file, use
  52. // this key instead of HKEY_CURRENT_USER. Do not close this
  53. // handle. Instead pass it to UnloadUserProfile to close
  54. // the handle.
  55. //
  56. //=============================================================================
  57. //
  58. // Flags that can be set in the dwFlags field
  59. //
  60. #define PI_NOUI 0x00000001 // Prevents displaying of messages
  61. #define PI_APPLYPOLICY 0x00000002 // Apply NT4 style policy
  62. #define PI_LITELOAD 0x00000004 // Lite load of the profile (for system use only) ;Internal
  63. #define PI_HIDEPROFILE 0x00000008 // Mark the profile as super hidden ;Internal
  64. USERENVAPI
  65. BOOL
  66. WINAPI
  67. LoadUserProfile%(
  68. IN HANDLE hToken,
  69. IN OUT LPPROFILEINFO% lpProfileInfo);
  70. //=============================================================================
  71. //
  72. // UnloadUserProfile
  73. //
  74. // Unloads a user's profile that was loaded by LoadUserProfile()
  75. //
  76. // hToken - Token for the user, returned from LogonUser()
  77. // hProfile - hProfile member of the PROFILEINFO structure
  78. //
  79. // Returns: TRUE if successful
  80. // FALSE if not. Call GetLastError() for more details
  81. //
  82. // Note: The caller of this function must have admin privileges on the machine.
  83. //
  84. //=============================================================================
  85. USERENVAPI
  86. BOOL
  87. WINAPI
  88. UnloadUserProfile(
  89. IN HANDLE hToken,
  90. IN HANDLE hProfile);
  91. //=============================================================================
  92. //
  93. // GetProfilesDirectory
  94. //
  95. // Returns the path to the root of where all user profiles are stored.
  96. //
  97. // lpProfilesDir - Receives the path
  98. // lpcchSize - Size of lpProfilesDir
  99. //
  100. // Returns: TRUE if successful
  101. // FALSE if not. Call GetLastError() for more details
  102. //
  103. // Note: If lpProfilesDir is not large enough, the function will fail,
  104. // and lpcchSize will contain the necessary buffer size.
  105. //
  106. // Example return value: C:\Documents and Settings
  107. //
  108. //=============================================================================
  109. USERENVAPI
  110. BOOL
  111. WINAPI
  112. GetProfilesDirectory%(
  113. OUT LPTSTR% lpProfilesDir,
  114. IN OUT LPDWORD lpcchSize);
  115. //=============================================================================
  116. //
  117. // GetProfileType()
  118. //
  119. // Returns the type of the profile that is loaded for a user.
  120. //
  121. // dwFlags - Returns the profile flags
  122. //
  123. // Return: TRUE if successful
  124. // FALSE if an error occurs. Call GetLastError for more details
  125. //
  126. // Comments: if profile is not already loaded the function will return an error.
  127. // The caller needs to have access to HKLM part of the registry.
  128. // (exists by default)
  129. //
  130. //=============================================================================
  131. ;begin_winver_500
  132. //
  133. // Flags that can be set in the dwFlags field
  134. //
  135. #define PT_TEMPORARY 0x00000001 // A profile has been allocated that will be deleted at logoff.
  136. #define PT_ROAMING 0x00000002 // The loaded profile is a roaming profile.
  137. #define PT_MANDATORY 0x00000004 // The loaded profile is mandatory.
  138. USERENVAPI
  139. BOOL
  140. WINAPI
  141. GetProfileType(
  142. OUT DWORD *dwFlags);
  143. ;end_winver_500
  144. //=============================================================================
  145. //
  146. // DeleteProfile()
  147. //
  148. // Deletes the profile and all other user related settings from the machine
  149. //
  150. // lpSidString - String form of the user sid.
  151. // lpProfilePath - ProfilePath (if Null, lookup in the registry)
  152. // lpComputerName - Computer Name from which profile has to be deleted
  153. //
  154. // Return: TRUE if successful
  155. // FALSE if an error occurs. Call GetLastError for more details
  156. //
  157. // Comments: Deletes the profile directory, registry and appmgmt stuff
  158. //=============================================================================
  159. ;begin_winver_500
  160. USERENVAPI
  161. BOOL
  162. WINAPI
  163. DeleteProfile% (
  164. IN LPCTSTR% lpSidString,
  165. IN LPCTSTR% lpProfilePath,
  166. IN LPCTSTR% lpComputerName);
  167. ;end_winver_500
  168. //=============================================================================
  169. //
  170. // GetDefaultUserProfilesDirectory
  171. //
  172. // Returns the path to the root of the default user profile
  173. //
  174. // lpProfileDir - Receives the path
  175. // lpcchSize - Size of lpProfileDir
  176. //
  177. // Returns: TRUE if successful
  178. // FALSE if not. Call GetLastError() for more details
  179. //
  180. // Note: If lpProfileDir is not large enough, the function will fail,
  181. // and lpcchSize will contain the necessary buffer size.
  182. //
  183. // Example return value: C:\Documents and Settings\Default User
  184. //
  185. //=============================================================================
  186. ;begin_winver_500
  187. USERENVAPI
  188. BOOL
  189. WINAPI
  190. GetDefaultUserProfileDirectory%(
  191. OUT LPTSTR% lpProfileDir,
  192. IN OUT LPDWORD lpcchSize);
  193. ;end_winver_500
  194. //=============================================================================
  195. //
  196. // GetAllUsersProfilesDirectory
  197. //
  198. // Returns the path to the root of the All Users profile
  199. //
  200. // lpProfileDir - Receives the path
  201. // lpcchSize - Size of lpProfileDir
  202. //
  203. // Returns: TRUE if successful
  204. // FALSE if not. Call GetLastError() for more details
  205. //
  206. // Note: If lpProfileDir is not large enough, the function will fail,
  207. // and lpcchSize will contain the necessary buffer size.
  208. //
  209. // Example return value: C:\Documents and Settings\All Users
  210. //
  211. //=============================================================================
  212. ;begin_winver_500
  213. USERENVAPI
  214. BOOL
  215. WINAPI
  216. GetAllUsersProfileDirectory%(
  217. OUT LPTSTR% lpProfileDir,
  218. IN OUT LPDWORD lpcchSize);
  219. ;end_winver_500
  220. //=============================================================================
  221. //
  222. // GetUserProfileDirectory
  223. //
  224. // Returns the path to the root of the requested user's profile
  225. //
  226. // hToken - User's token returned from LogonUser()
  227. // lpProfileDir - Receives the path
  228. // lpcchSize - Size of lpProfileDir
  229. //
  230. // Returns: TRUE if successful
  231. // FALSE if not. Call GetLastError() for more details
  232. //
  233. // Note: If lpProfileDir is not large enough, the function will fail,
  234. // and lpcchSize will contain the necessary buffer size.
  235. //
  236. // Example return value: C:\Documents and Settings\Joe
  237. //
  238. //=============================================================================
  239. USERENVAPI
  240. BOOL
  241. WINAPI
  242. GetUserProfileDirectory%(
  243. IN HANDLE hToken,
  244. OUT LPTSTR% lpProfileDir,
  245. IN OUT LPDWORD lpcchSize);
  246. //=============================================================================
  247. //
  248. // CreateEnvironmentBlock
  249. //
  250. // Returns the environment variables for the specified user. This block
  251. // can then be passed to CreateProcessAsUser().
  252. //
  253. // lpEnvironment - Receives a pointer to the new environment block
  254. // hToken - User's token returned from LogonUser() (optional, can be NULL)
  255. // bInherit - Inherit from the current process's environment block
  256. // or start from a clean state.
  257. //
  258. // Returns: TRUE if successful
  259. // FALSE if not. Call GetLastError() for more details
  260. //
  261. // Note: If hToken is NULL, the returned environment block will contain
  262. // system variables only.
  263. //
  264. // Call DestroyEnvironmentBlock to free the buffer when finished.
  265. //
  266. // If this block is passed to CreateProcessAsUser, the
  267. // CREATE_UNICODE_ENVIRONMENT flag must also be set.
  268. //
  269. //=============================================================================
  270. USERENVAPI
  271. BOOL
  272. WINAPI
  273. CreateEnvironmentBlock(
  274. OUT LPVOID *lpEnvironment,
  275. IN HANDLE hToken,
  276. IN BOOL bInherit);
  277. //=============================================================================
  278. //
  279. // DestroyEnvironmentBlock
  280. //
  281. // Frees environment variables created by CreateEnvironmentBlock
  282. //
  283. // lpEnvironment - A pointer to the environment block
  284. //
  285. // Returns: TRUE if successful
  286. // FALSE if not. Call GetLastError() for more details
  287. //
  288. //=============================================================================
  289. USERENVAPI
  290. BOOL
  291. WINAPI
  292. DestroyEnvironmentBlock(
  293. IN LPVOID lpEnvironment);
  294. //=============================================================================
  295. //
  296. // ExpandEnvironmentStringsForUser
  297. //
  298. // Expands the source string using the environment block for the
  299. // specified user. If hToken is null, the system environment block
  300. // will be used (no user environment variables).
  301. //
  302. // hToken - User's token returned from LogonUser() (optional, can be NULL)
  303. // lpSrc - Pointer to the string with environment variables
  304. // lpDest - Buffer that receives the expanded string
  305. // dwSize - Size of lpDest in characters (max chars)
  306. //
  307. // Returns: TRUE if successful
  308. // FALSE if not. Call GetLastError() for more details
  309. //
  310. // Note: If the user profile for hToken is not loaded, this api will fail.
  311. //
  312. //=============================================================================
  313. ;begin_winver_500
  314. USERENVAPI
  315. BOOL
  316. WINAPI
  317. ExpandEnvironmentStringsForUser%(
  318. IN HANDLE hToken,
  319. IN LPCTSTR% lpSrc,
  320. OUT LPTSTR% lpDest,
  321. IN DWORD dwSize);
  322. ;end_winver_500
  323. //=============================================================================
  324. //
  325. // RefreshPolicy()
  326. //
  327. // Causes group policy to be applied immediately on the client machine
  328. //
  329. // bMachine - Refresh machine or user policy
  330. //
  331. // Returns: TRUE if successful
  332. // FALSE if not. Call GetLastError() for more details
  333. //
  334. //=============================================================================
  335. ;begin_winver_500
  336. USERENVAPI
  337. BOOL
  338. WINAPI
  339. RefreshPolicy(
  340. IN BOOL bMachine);
  341. ;end_winver_500
  342. //=============================================================================
  343. //
  344. // RefreshPolicyEx()
  345. //
  346. // Causes group policy to be applied immediately on the client machine.
  347. //
  348. // bMachine - Refresh machine or user policy
  349. // dwOptions - Option specifying the kind of refresh that needs to be done.
  350. //
  351. // Returns: TRUE if successful
  352. // FALSE if not. Call GetLastError() for more details
  353. //
  354. //=============================================================================
  355. ;begin_winver_500
  356. #define RP_FORCE 1 // Refresh policies without any optimisations.
  357. USERENVAPI
  358. BOOL
  359. WINAPI
  360. RefreshPolicyEx(
  361. IN BOOL bMachine, IN DWORD dwOptions);
  362. ;end_winver_500
  363. //=============================================================================
  364. //
  365. // EnterCriticalPolicySection
  366. //
  367. // Pauses the background application of group policy to allow safe
  368. // reading of the registry. Applications that need to read multiple
  369. // policy entries and ensure that the values are not changed while reading
  370. // them should use this function.
  371. //
  372. // The maximum amount of time an application can hold a critical section
  373. // is 10 minutes. After 10 minutes, policy can be applied again.
  374. //
  375. // bMachine - Pause machine or user policy
  376. //
  377. // Returns: Handle if successful
  378. // NULL if not. Call GetLastError() for more details
  379. //
  380. // Note 1: The handle returned should be passed to LeaveCriticalPolicySection
  381. // when finished. Do not close this handle, LeaveCriticalPolicySection
  382. // will do that.
  383. //
  384. // Note 2: If both user and machine critical sections need to be acquired then
  385. // they should be done in this order: first acquire user critical section and
  386. // then acquire machine critical section.
  387. //
  388. //=============================================================================
  389. ;begin_winver_500
  390. USERENVAPI
  391. HANDLE
  392. WINAPI
  393. EnterCriticalPolicySection(
  394. IN BOOL bMachine);
  395. ;end_winver_500
  396. //=============================================================================
  397. //
  398. // LeaveCriticalPolicySection
  399. //
  400. // Resumes the background application of group policy. See
  401. // EnterCriticalPolicySection for more details.
  402. //
  403. // hSection - Handle returned from EnterCriticalPolicySection
  404. //
  405. // Returns: TRUE if successful
  406. // FALSE if not. Call GetLastError() for more details
  407. //
  408. // Note: This function will close the handle.
  409. //
  410. //=============================================================================
  411. ;begin_winver_500
  412. USERENVAPI
  413. BOOL
  414. WINAPI
  415. LeaveCriticalPolicySection(
  416. IN HANDLE hSection);
  417. ;end_winver_500
  418. //=============================================================================
  419. //
  420. // RegisterGPNotification
  421. //
  422. // Entry point for registering for Group Policy change notification.
  423. //
  424. // Parameters: hEvent - Event to be notified, by calling SetEvent(hEvent)
  425. // bMachine - If true, then register machine policy notification
  426. // else register user policy notification
  427. //
  428. // Returns: True if successful
  429. // False if error occurs
  430. //
  431. // Notes: Group Policy Notifications. There are 2 ways an application can
  432. // be notify when Group Policy is finished being applied.
  433. //
  434. // 1) Using the RegisterGPNotifcation function and waiting for the
  435. // event to be signalled.
  436. //
  437. // 2) A WM_SETTINGCHANGE message is broadcast to all desktops.
  438. // wParam - 1 if machine policy was applied, 0 if user policy was applied.
  439. // lParam - Points to the string "Policy"
  440. //
  441. //=============================================================================
  442. ;begin_winver_500
  443. USERENVAPI
  444. BOOL
  445. WINAPI
  446. RegisterGPNotification(
  447. IN HANDLE hEvent,
  448. IN BOOL bMachine );
  449. ;end_winver_500
  450. //=============================================================================
  451. //
  452. // UnregisterGPNotification
  453. //
  454. // Removes registration for a Group Policy change notification.
  455. //
  456. // Parameters: hEvent - Event to be removed
  457. //
  458. // Returns: True if successful
  459. // False if error occurs
  460. //
  461. //=============================================================================
  462. ;begin_winver_500
  463. USERENVAPI
  464. BOOL
  465. WINAPI
  466. UnregisterGPNotification(
  467. IN HANDLE hEvent );
  468. ;end_winver_500
  469. //=============================================================================
  470. //
  471. // GPOptions flags
  472. //
  473. // These are the flags found in the GPOptions property of a DS object
  474. //
  475. // For a given DS object (Site, Domain, OU), the GPOptions property
  476. // contains options that effect all the GPOs link to this SDOU.
  477. //
  478. // This is a DWORD type
  479. //
  480. //=============================================================================
  481. ;begin_winver_500
  482. #define GPC_BLOCK_POLICY 0x00000001 // Block all non-forced policy from above
  483. ;end_winver_500
  484. //=============================================================================
  485. //
  486. // GPLink flags
  487. //
  488. // These are the flags found on the GPLink property of a DS object after
  489. // the GPO path.
  490. //
  491. // For a given DS object (Site, Domain, OU), the GPLink property will
  492. // be in this text format
  493. //
  494. // [LDAP://CN={E615A0E3-C4F1-11D1-A3A7-00AA00615092},CN=Policies,CN=System,DC=mydomain,DC=Microsoft,DC=Com;1]
  495. //
  496. // The GUID is the GPO name, and the number following the LDAP path are the options
  497. // for that link from this DS object. Note, there can be multiple GPOs
  498. // each in their own square brackets in a prioritized list.
  499. //
  500. //=============================================================================
  501. ;begin_winver_500
  502. //
  503. // Options for a GPO link
  504. //
  505. #define GPO_FLAG_DISABLE 0x00000001 // This GPO is disabled
  506. #define GPO_FLAG_FORCE 0x00000002 // Don't override the settings in
  507. // this GPO with settings from
  508. // a GPO below it.
  509. ;end_winver_500
  510. //=============================================================================
  511. //
  512. // GetGPOList
  513. //
  514. //
  515. // Queries for the list of Group Policy Objects for the specified
  516. // user or machine. This function will return a link list
  517. // of Group Policy Objects. Call FreeGPOList to free the list.
  518. //
  519. // Note, most applications will not need to call this function.
  520. // This will primarily be used by services acting on behalf of
  521. // another user or machine. The caller of this function will
  522. // need to look in each GPO for their specific policy
  523. //
  524. // This function can be called in two different ways. Either the hToken for
  525. // a user or machine can be supplied and the correct name and domain
  526. // controller name will be generated, or hToken is NULL and the caller
  527. // must supply the name and the domain controller name.
  528. //
  529. // Calling this function with an hToken ensures the list of Group Policy
  530. // Objects is correct for the user or machine since security access checking
  531. // can be perfomed. If hToken is not supplied, the security of the caller
  532. // is used instead which means that list may or may not be 100% correct
  533. // for the intended user / machine. However, this is the fastest way
  534. // to call this function.
  535. //
  536. // hToken - User or machine token, if NULL, lpName and lpHostName must be supplied
  537. // lpName - User or machine name in DN format, if hToken is supplied, this must be NULL
  538. // lpHostName - Domain DN name or domain controller name. If hToken is supplied, this must be NULL
  539. // lpComputerName - Computer name to use to determine site location. If NULL,
  540. // the local computer is used as the reference. Format: \\machinename
  541. // dwFlags - Flags field. See flags definition below
  542. // pGPOList - Address of a pointer which receives the link list of GPOs
  543. //
  544. //
  545. // Returns: TRUE if successful
  546. // FALSE if not. Use GetLastError() for more details.
  547. //
  548. // Examples:
  549. //
  550. // Here's how this function will typically be called for
  551. // looking up the list of GPOs for a user:
  552. //
  553. // LPGROUP_POLICY_OBJECT pGPOList;
  554. //
  555. // if (GetGPOList (hToken, NULL, NULL, NULL, 0, &pGPOList))
  556. // {
  557. // // do processing here...
  558. // FreeGPOList (pGPOList);
  559. // }
  560. //
  561. //
  562. // Here's how this function will typically be called for
  563. // looking up the list of GPOs for a machine:
  564. //
  565. // LPGROUP_POLICY_OBJECT pGPOList;
  566. //
  567. // if (GetGPOList (NULL, lpMachineName, lpHostName, lpMachineName,
  568. // GPO_LIST_FLAG_MACHINE, &pGPOList))
  569. // {
  570. // // do processing here...
  571. // FreeGPOList (pGPOList);
  572. // }
  573. //
  574. //=============================================================================
  575. ;begin_winver_500
  576. //
  577. // Each Group Policy Object is associated (linked) with a site, domain,
  578. // organizational unit, or machine.
  579. //
  580. typedef enum _GPO_LINK {
  581. GPLinkUnknown = 0, // No link information available
  582. GPLinkMachine, // GPO linked to a machine (local or remote)
  583. GPLinkSite, // GPO linked to a site
  584. GPLinkDomain, // GPO linked to a domain
  585. GPLinkOrganizationalUnit // GPO linked to a organizational unit
  586. } GPO_LINK, *PGPO_LINK;
  587. typedef struct _GROUP_POLICY_OBJECT% {
  588. DWORD dwOptions; // See GPLink option flags above
  589. DWORD dwVersion; // Revision number of the GPO
  590. LPTSTR% lpDSPath; // Path to the Active Directory portion of the GPO
  591. LPTSTR% lpFileSysPath; // Path to the file system portion of the GPO
  592. LPTSTR% lpDisplayName; // Friendly display name
  593. TCHAR% szGPOName[50]; // Unique name
  594. GPO_LINK GPOLink; // Link information
  595. LPARAM lParam; // Free space for the caller to store GPO specific information
  596. struct _GROUP_POLICY_OBJECT% * pNext; // Next GPO in the list
  597. struct _GROUP_POLICY_OBJECT% * pPrev; // Previous GPO in the list
  598. LPTSTR% lpExtensions; // Extensions that are relevant for this GPO
  599. LPARAM lParam2; // Free space for the caller to store GPO specific information
  600. LPTSTR% lpLink; // Path to the Active Directory site, domain, or organizational unit this GPO is linked to
  601. // If this is the local GPO, this points to the word "Local"
  602. } GROUP_POLICY_OBJECT%, *PGROUP_POLICY_OBJECT%;
  603. //
  604. // dwFlags for GetGPOList()
  605. //
  606. #define GPO_LIST_FLAG_MACHINE 0x00000001 // Return machine policy information
  607. #define GPO_LIST_FLAG_SITEONLY 0x00000002 // Return site policy information only
  608. USERENVAPI
  609. BOOL
  610. WINAPI
  611. GetGPOList% (
  612. IN HANDLE hToken,
  613. IN LPCTSTR% lpName,
  614. IN LPCTSTR% lpHostName,
  615. IN LPCTSTR% lpComputerName,
  616. IN DWORD dwFlags,
  617. OUT PGROUP_POLICY_OBJECT% *pGPOList);
  618. ;end_winver_500
  619. //=============================================================================
  620. //
  621. // FreeGPOList
  622. //
  623. //
  624. // Frees the linked list returned from GetGPOList
  625. //
  626. // pGPOList - Pointer to the linked list of GPOs
  627. //
  628. //
  629. // Returns: TRUE if successful
  630. // FALSE if not
  631. //
  632. //=============================================================================
  633. ;begin_winver_500
  634. USERENVAPI
  635. BOOL
  636. WINAPI
  637. FreeGPOList% (
  638. IN PGROUP_POLICY_OBJECT% pGPOList);
  639. ;end_winver_500
  640. //=============================================================================
  641. //
  642. // GetAppliedGPOList
  643. //
  644. // Queries for the list of applied Group Policy Objects for the specified
  645. // user or machine and specified client side extension. This function will return
  646. // a linked list of Group Policy Objects. Call FreeGPOList to free the list.
  647. //
  648. // dwFlags - User or machine policy, if it is GPO_LIST_FLAG_MACHINE then
  649. // return machine policy information
  650. // pMachineName - Name of remote computer in the form \\computername. If null
  651. // then local computer is used.
  652. // pSidUser - Security id of user (relevant for user policy). If pMachineName is
  653. // null and pSidUser is null then it means current logged on user.
  654. // If pMachine is null and pSidUser is non-null then it means user
  655. // represented by pSidUser on local machine. If pMachineName is non-null
  656. // then and if dwFlags specifies user policy, then pSidUser must be
  657. // non-null.
  658. // pGuidExtension - Guid of the specified extension
  659. // ppGPOList - Address of a pointer which receives the link list of GPOs
  660. //
  661. // The return value is a Win32 error code. ERROR_SUCCESS means the GetAppliedGPOList
  662. // function completed successfully. Otherwise it indicates that the function failed.
  663. //
  664. //=============================================================================
  665. ;begin_winver_500
  666. USERENVAPI
  667. DWORD
  668. WINAPI
  669. GetAppliedGPOList% (
  670. IN DWORD dwFlags,
  671. IN LPCTSTR% pMachineName,
  672. IN PSID pSidUser,
  673. IN GUID *pGuidExtension,
  674. OUT PGROUP_POLICY_OBJECT% *ppGPOList);
  675. ;end_winver_500
  676. //=============================================================================
  677. //
  678. // Group Policy Object client side extension support
  679. //
  680. // Flags, data structures and function prototype
  681. //
  682. // To register your extension, create a subkey under this key
  683. //
  684. // Software\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions
  685. //
  686. // The subkey needs to be a guid so that it is unique. The noname value of the subkey
  687. // can be the friendly name of the extension. Then add these values:
  688. //
  689. // DllName REG_EXPAND_SZ Path to your DLL
  690. // ProcessGroupPolicy REG_SZ Function name (see PFNPROCESSGROUPPOLICY prototype). This
  691. // is obsolete, it has been superseded by ProcessGroupPolicyEx.
  692. // It's here for backward compatibility reasons only.
  693. // ProcessGroupPolicyEx REG_SZ Function name (see PFNPROCESSGROUPPOLICYEX prototype)
  694. // GenerateGroupPolicy REG_SZ Function name for Rsop (see PFNGENERATEGROUPPOLICY prototype)
  695. // NoMachinePolicy REG_DWORD True, if extension does not have to be called when
  696. // machine policies are being processed.
  697. // NoUserPolicy REG_DWORD True, if extension does not have to be called when
  698. // user policies are being processed.
  699. // NoSlowLink REG_DWORD True, if extension does not have to be called on a slow link
  700. // NoBackgroundPolicy REG_DWORD True, if extension does not have to be called
  701. // for background policy processing.
  702. // NoGPOListChanges REG_DWORD True, if extension does not have to be called when
  703. // there are no changes between cached and current GPO lists.
  704. // PerUserLocalSettings REG_DWORD True, if user policies have to be cached on a per user and
  705. // per machine basis.
  706. // RequiresSuccessfulRegistry REG_DWORD True, if extension should be called only if registry extension
  707. // was successfully processed.
  708. // EnableAsynchronousProcessing REG_DWORD True, if registry extension will complete its processing
  709. // asynchronously.
  710. // NotifyLinkTransition REG_DWORD True, if extension should be called when a change in link
  711. // speed is detected between previous policy application and
  712. // current policy application.
  713. //
  714. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicy
  715. // function completed successfully. If return value is ERROR_OVERRIDE_NOCHANGES then it
  716. // means that the extension will be called the next time even if NoGPOListChanges is set
  717. // and there are no changes to the GPO list. Any other return value indicates that the
  718. // ProcessGroupPolicy or ProcessGroupPolicyEx function failed.
  719. //
  720. //=============================================================================
  721. ;begin_winver_500
  722. #define GP_DLLNAME TEXT("DllName")
  723. #define GP_ENABLEASYNCHRONOUSPROCESSING TEXT("EnableAsynchronousProcessing")
  724. #define GP_MAXNOGPOLISTCHANGESINTERVAL TEXT("MaxNoGPOListChangesInterval")
  725. #define GP_NOBACKGROUNDPOLICY TEXT("NoBackgroundPolicy")
  726. #define GP_NOGPOLISTCHANGES TEXT("NoGPOListChanges")
  727. #define GP_NOMACHINEPOLICY TEXT("NoMachinePolicy")
  728. #define GP_NOSLOWLINK TEXT("NoSlowLink")
  729. #define GP_NOTIFYLINKTRANSITION TEXT("NotifyLinkTransition")
  730. #define GP_NOUSERPOLICY TEXT("NoUserPolicy")
  731. #define GP_PERUSERLOCALSETTINGS TEXT("PerUserLocalSettings")
  732. #define GP_PROCESSGROUPPOLICY TEXT("ProcessGroupPolicy")
  733. #define GP_REQUIRESSUCCESSFULREGISTRY TEXT("RequiresSuccessfulRegistry")
  734. #define GPO_INFO_FLAG_MACHINE 0x00000001 // Apply machine policy rather than user policy
  735. #define GPO_INFO_FLAG_BACKGROUND 0x00000010 // Background refresh of policy (ok to do slow stuff)
  736. #define GPO_INFO_FLAG_SLOWLINK 0x00000020 // Policy is being applied across a slow link
  737. #define GPO_INFO_FLAG_VERBOSE 0x00000040 // Verbose output to the eventlog
  738. #define GPO_INFO_FLAG_NOCHANGES 0x00000080 // No changes were detected to the Group Policy Objects
  739. #define GPO_INFO_FLAG_LINKTRANSITION 0x00000100 // A change in link speed was detected between previous policy
  740. // application and current policy application
  741. #define GPO_INFO_FLAG_LOGRSOP_TRANSITION 0x00000200 // A Change in Rsop Logging was detected between previous policy
  742. // application and current policy application, (new intf only)
  743. #define GPO_INFO_FLAG_FORCED_REFRESH 0x00000400 // Forced Refresh is being applied. redo policies.
  744. #define GPO_INFO_FLAG_SAFEMODE_BOOT 0x00000800 // windows safe mode boot flag
  745. #define GPO_INFO_FLAG_ASYNC_FOREGROUND 0x00001000 // Asynchronous foreground refresh of policy
  746. #define GPO_INFO_FLAG_REPORT 0x00002000 // Report all settings for one GPO rather than the resultant settings across multiple GPOs
  747. typedef UINT_PTR ASYNCCOMPLETIONHANDLE;
  748. typedef DWORD (*PFNSTATUSMESSAGECALLBACK)(BOOL bVerbose, LPWSTR lpMessage);
  749. typedef DWORD(*PFNPROCESSGROUPPOLICY)(
  750. IN DWORD dwFlags, // GPO_INFO_FLAGS
  751. IN HANDLE hToken, // User or machine token
  752. IN HKEY hKeyRoot, // Root of registry
  753. IN PGROUP_POLICY_OBJECT pDeletedGPOList, // Linked list of deleted GPOs
  754. IN PGROUP_POLICY_OBJECT pChangedGPOList, // Linked list of changed GPOs
  755. IN ASYNCCOMPLETIONHANDLE pHandle, // For asynchronous completion
  756. IN BOOL *pbAbort, // If true, then abort GPO processing
  757. IN PFNSTATUSMESSAGECALLBACK pStatusCallback); // Callback function for displaying status messages
  758. // Note, this can be NULL
  759. typedef DWORD(*PFNPROCESSGROUPPOLICYEX)(
  760. IN DWORD dwFlags, // GPO_INFO_FLAGS
  761. IN HANDLE hToken, // User or machine token
  762. IN HKEY hKeyRoot, // Root of registry
  763. IN PGROUP_POLICY_OBJECT pDeletedGPOList, // Linked list of deleted GPOs
  764. IN PGROUP_POLICY_OBJECT pChangedGPOList, // Linked list of changed GPOs
  765. IN ASYNCCOMPLETIONHANDLE pHandle, // For asynchronous completion
  766. IN BOOL *pbAbort, // If true, then abort GPO processing
  767. IN PFNSTATUSMESSAGECALLBACK pStatusCallback, // Callback function for displaying status messages
  768. // Note, this can be NULL
  769. IN IWbemServices *pWbemServices, // Pointer to namespace to log diagnostic mode data
  770. // Note, this will be NULL when Rsop logging is disabled
  771. OUT HRESULT *pRsopStatus); // RSOP Logging succeeded or not.
  772. typedef PVOID PRSOPTOKEN;
  773. typedef struct _RSOP_TARGET {
  774. WCHAR * pwszAccountName; // Account name
  775. WCHAR * pwszNewSOM; // New domain or OU location for account
  776. SAFEARRAY * psaSecurityGroups; // New security groups
  777. PRSOPTOKEN pRsopToken; // Rsop token for use with Rsop security Api's
  778. PGROUP_POLICY_OBJECT pGPOList; // Linked list of GPOs
  779. IWbemServices * pWbemServices; // Pointer to namespace to log planning mode data
  780. } RSOP_TARGET, *PRSOP_TARGET;
  781. typedef DWORD(*PFNGENERATEGROUPPOLICY)(
  782. IN DWORD dwFlags, // GPO_INFO_FLAGS
  783. IN BOOL *pbAbort, // If true, then abort GPO processing
  784. IN WCHAR *pwszSite, // Site the target computer is in
  785. IN PRSOP_TARGET pComputerTarget, // Computer target info, can be null
  786. IN PRSOP_TARGET pUserTarget ); // User target info, can be null
  787. //
  788. // GUID that identifies the registry extension
  789. //
  790. #define REGISTRY_EXTENSION_GUID { 0x35378EAC, 0x683F, 0x11D2, 0xA8, 0x9A, 0x00, 0xC0, 0x4F, 0xBB, 0xCF, 0xA2 }
  791. ;end_winver_500
  792. //=============================================================================
  793. //
  794. // Group Policy Object client side asynchronous extension processing
  795. //
  796. // extensionId - Unique guid identifying the extension
  797. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  798. // ProcessGroupPolicy call
  799. // dwStatus - Completion status of asynchronous processing
  800. //
  801. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  802. // function completed successfully. Otherwise it indicates that the function failed.
  803. //
  804. //=============================================================================
  805. ;begin_winver_500
  806. typedef GUID *REFGPEXTENSIONID;
  807. USERENVAPI
  808. DWORD
  809. WINAPI
  810. ProcessGroupPolicyCompleted(
  811. IN REFGPEXTENSIONID extensionId,
  812. IN ASYNCCOMPLETIONHANDLE pAsyncHandle,
  813. IN DWORD dwStatus);
  814. ;end_winver_500
  815. //=============================================================================
  816. //
  817. // Group Policy Object client side asynchronous extension processing
  818. //
  819. // extensionId - Unique guid identifying the extension
  820. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  821. // ProcessGroupPolicy call
  822. // dwStatus - Completion status of asynchronous processing
  823. // RsopStatus - RSoP Logging status
  824. //
  825. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  826. // function completed successfully. Otherwise it indicates that the function failed.
  827. //
  828. //=============================================================================
  829. ;begin_winver_500
  830. USERENVAPI
  831. DWORD
  832. WINAPI
  833. ProcessGroupPolicyCompletedEx(
  834. IN REFGPEXTENSIONID extensionId,
  835. IN ASYNCCOMPLETIONHANDLE pAsyncHandle,
  836. IN DWORD dwStatus,
  837. IN HRESULT RsopStatus);
  838. ;end_winver_500
  839. //=============================================================================
  840. //
  841. // Function: RsopAccessCheckByType
  842. //
  843. // Description: Determines whether the security descriptor pointed to by pSecurityDescriptor
  844. // grants the set of access rights specified in dwDesiredAccessMask
  845. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  846. //
  847. // pSecurityDescriptor - Security Descriptor on the object
  848. // pPrincipalSelfSid - Principal Sid
  849. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  850. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  851. // pObjectTypeList - Object Type List
  852. // ObjectTypeListLength - Object Type List Length
  853. // pGenericMapping - Generic Mapping
  854. // pPrivilegeSet - privilege set
  855. // pdwPrivilegeSetLength- privilege set length
  856. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  857. // the mask of standard and specific rights granted.
  858. // If pbAccessStatus is false, it is set to 0.
  859. // On failure, it is not modified.
  860. // pbAccessStatus - On success, indicates wether the requested set
  861. // of access rights was granted.
  862. // On failure, it is not modified
  863. //
  864. // Returns S_OK on success or appropriate error code.
  865. // For additional details, look at the documentation of AccessCheckByType
  866. //=============================================================================
  867. ;begin_winver_500
  868. USERENVAPI
  869. HRESULT
  870. WINAPI
  871. RsopAccessCheckByType(
  872. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  873. IN PSID pPrincipalSelfSid,
  874. IN PRSOPTOKEN pRsopToken,
  875. IN DWORD dwDesiredAccessMask,
  876. IN POBJECT_TYPE_LIST pObjectTypeList,
  877. IN DWORD ObjectTypeListLength,
  878. IN PGENERIC_MAPPING pGenericMapping,
  879. IN PPRIVILEGE_SET pPrivilegeSet,
  880. IN LPDWORD pdwPrivilegeSetLength,
  881. OUT LPDWORD pdwGrantedAccessMask,
  882. OUT LPBOOL pbAccessStatus);
  883. ;end_winver_500
  884. //=============================================================================
  885. //
  886. // Function: RsopFileAccessCheck
  887. //
  888. // Description: Determines whether the security descriptor on the file grants the set of file access
  889. // rights specified in dwDesiredAccessMask
  890. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  891. //
  892. // pszFileName - Name of an existing filename
  893. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  894. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  895. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  896. // the mask of standard and specific rights granted.
  897. // If pbAccessStatus is false, it is set to 0.
  898. // On failure, it is not modified.
  899. // pbAccessStatus - On success, indicates wether the requested set
  900. // of access rights was granted.
  901. // On failure, it is not modified
  902. //
  903. // Returns S_OK on success or appropriate error code
  904. //=============================================================================
  905. ;begin_winver_500
  906. USERENVAPI
  907. HRESULT
  908. WINAPI
  909. RsopFileAccessCheck(
  910. IN LPWSTR pszFileName,
  911. IN PRSOPTOKEN pRsopToken,
  912. IN DWORD dwDesiredAccessMask,
  913. OUT LPDWORD pdwGrantedAccessMask,
  914. OUT LPBOOL pbAccessStatus);
  915. ;end_winver_500
  916. typedef enum _SETTINGSTATUS
  917. {
  918. RSOPUnspecified = 0,
  919. RSOPApplied,
  920. RSOPIgnored,
  921. RSOPFailed,
  922. RSOPSubsettingFailed
  923. } SETTINGSTATUS;
  924. //=============================================================================
  925. //
  926. // POLICYSETTINGSTATUSINFO
  927. //
  928. // Describes the instance of RSOP_PolicySettingStatus
  929. //
  930. // szKey - OPTIONAL, if NULL, the key is generated on the fly
  931. // szEventSource - name of the source generation event log messages
  932. // szEventLogName - name of the event log database where the messages are logged
  933. // dwEventID - event log message ID
  934. // status - status of the policy setting
  935. // timeLogged - time at which the event log message was logged
  936. //
  937. //=============================================================================
  938. typedef struct _POLICYSETTINGSTATUSINFO
  939. {
  940. LPWSTR szKey;
  941. LPWSTR szEventSource;
  942. LPWSTR szEventLogName;
  943. DWORD dwEventID;
  944. DWORD dwErrorCode;
  945. SETTINGSTATUS status;
  946. SYSTEMTIME timeLogged;
  947. } POLICYSETTINGSTATUSINFO, *LPPOLICYSETTINGSTATUSINFO;
  948. //=============================================================================
  949. //
  950. // RsopSetPolicySettingStatus
  951. //
  952. // Creates an instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  953. // and links RSOP_PolicySettingStatus to RSOP_PolicySetting
  954. //
  955. // dwFlags - flags
  956. // pServices - RSOP namespace
  957. // pSettingInstance - instance of RSOP_PolicySetting or its children
  958. // nInfo - number of PolicySettingStatusInfo
  959. // pStatus - array of PolicySettingStatusInfo
  960. //
  961. // Return: S_OK if successful, HRESULT otherwise
  962. //
  963. //=============================================================================
  964. USERENVAPI
  965. HRESULT
  966. WINAPI
  967. RsopSetPolicySettingStatus( DWORD dwFlags,
  968. IWbemServices* pServices,
  969. IWbemClassObject* pSettingInstance,
  970. DWORD nInfo,
  971. POLICYSETTINGSTATUSINFO* pStatus );
  972. //=============================================================================
  973. //
  974. // RsopResetPolicySettingStatus
  975. //
  976. // Unlinks RSOP_PolicySettingStatus from RSOP_PolicySetting,
  977. // deletes the instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  978. // and optionally deletes the instance of RSOP_PolicySetting
  979. //
  980. // dwFlags - flags
  981. // pServices - RSOP namespace
  982. // pSettingInstance - instance of RSOP_PolicySetting or its children
  983. //
  984. // Return: S_OK if successful, HRESULT otherwise
  985. //
  986. //=============================================================================
  987. USERENVAPI
  988. HRESULT
  989. WINAPI
  990. RsopResetPolicySettingStatus( DWORD dwFlags,
  991. IWbemServices* pServices,
  992. IWbemClassObject* pSettingInstance );
  993. //=============================================================================
  994. //
  995. // Flags for RSoP WMI providers
  996. //
  997. //=============================================================================
  998. // planning mode provider flags
  999. #define FLAG_NO_GPO_FILTER 0x80000000 // GPOs are not filtered, implies FLAG_NO_CSE_INVOKE
  1000. #define FLAG_NO_CSE_INVOKE 0x40000000 // only GP processing done for planning mode
  1001. #define FLAG_ASSUME_SLOW_LINK 0x20000000 // planning mode RSoP assumes slow link
  1002. #define FLAG_LOOPBACK_MERGE 0x10000000 // planning mode RSoP assumes merge loop back
  1003. #define FLAG_LOOPBACK_REPLACE 0x08000000 // planning mode RSoP assumes replace loop back
  1004. #define FLAG_ASSUME_USER_WQLFILTER_TRUE 0x04000000 // planning mode RSoP assumes all comp filters to be true
  1005. #define FLAG_ASSUME_COMP_WQLFILTER_TRUE 0x02000000 // planning mode RSoP assumes all user filters to be true
  1006. #define FLAG_PLANNING_MODE 0x01000000 // flag that indicates that a given namespace was created
  1007. // for planning mode. This flag cannot be passed in but the
  1008. // relevant subnamespace will be marked with this flag
  1009. // diagnostic mode provider flags
  1010. #define FLAG_NO_USER 0x00000001 // Don't get any user data
  1011. #define FLAG_NO_COMPUTER 0x00000002 // Don't get any machine data
  1012. #define FLAG_FORCE_CREATENAMESPACE 0x00000004
  1013. // Delete and recreate the namespace for this snapshot.
  1014. //=============================================================================
  1015. //
  1016. // Extended Errors returned by RSoP WMI Providers
  1017. //
  1018. //=============================================================================
  1019. // User accessing the rsop provider doesn't have access to user data.
  1020. #define RSOP_USER_ACCESS_DENIED 0x00000001
  1021. // User accessing the rsop provider doesn't have access to computer data.
  1022. #define RSOP_COMPUTER_ACCESS_DENIED 0x00000002
  1023. // This user is an interactive non admin user, the temp snapshot namespace already exists
  1024. // and the FLAG_FORCE_CREATENAMESPACE was not passed in
  1025. #define RSOP_TEMPNAMESPACE_EXISTS 0x00000004
  1026. ;begin_internal
  1027. #ifndef _USERENV_NO_LINK_APIS_
  1028. //=============================================================================
  1029. //
  1030. // Internal flags for RSoP WMI providers
  1031. //
  1032. //=============================================================================
  1033. // planning mode provider flags
  1034. #define FLAG_INTERNAL_MASK 0x01FFFFFF
  1035. //=============================w================================================
  1036. //
  1037. // CreateGroup
  1038. //
  1039. // Creates a program group on the start menu
  1040. //
  1041. // lpGroupName - Name of group
  1042. // bCommonGroup - Common or personal group
  1043. //
  1044. // Returns: TRUE if successful
  1045. // FALSE if not. Call GetLastError() for more details
  1046. //
  1047. //=============================================================================
  1048. USERENVAPI
  1049. BOOL
  1050. WINAPI
  1051. CreateGroup%(
  1052. IN LPCTSTR% lpGroupName,
  1053. IN BOOL bCommonGroup);
  1054. //=============================================================================
  1055. //
  1056. // CreateGroupEx
  1057. //
  1058. // Creates a program group on the start menu
  1059. //
  1060. // lpGroupName - Name of group
  1061. // bCommonGroup - Common or personal group
  1062. // lpResourceModuleName - Name of the resource module.
  1063. // uResourceID - Resource ID for the MUI display name.
  1064. //
  1065. // Returns: TRUE if successful
  1066. // FALSE if not. Call GetLastError() for more details
  1067. //
  1068. //=============================================================================
  1069. USERENVAPI
  1070. BOOL
  1071. WINAPI
  1072. CreateGroupEx%(
  1073. IN LPCTSTR% lpGroupName,
  1074. IN BOOL bCommonGroup,
  1075. IN LPCTSTR% lpResourceModuleName,
  1076. IN UINT uResourceID);
  1077. //=============================================================================
  1078. //
  1079. // DeleteGroup
  1080. //
  1081. // Deletes a program group on the start menu and all of its contents
  1082. //
  1083. // lpGroupName - Name of group
  1084. // bCommonGroup - Common or personal group
  1085. //
  1086. // Returns: TRUE if successful
  1087. // FALSE if not. Call GetLastError() for more details
  1088. //
  1089. // Note: This function uses a delnode routine. Make sure you really want
  1090. // to delete the group before you call this function.
  1091. //
  1092. //=============================================================================
  1093. USERENVAPI
  1094. BOOL
  1095. WINAPI
  1096. DeleteGroup%(
  1097. IN LPCTSTR% lpGroupName,
  1098. IN BOOL bCommonGroup);
  1099. //=============================================================================
  1100. //
  1101. // AddItem
  1102. //
  1103. // Creates an item on the Programs portion of the Start Menu in the
  1104. // requested group.
  1105. //
  1106. // lpGroupName - Name of group
  1107. // bCommonGroup - Common or personal group
  1108. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1109. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1110. // lpIconPath - Optional icon path, can be NULL.
  1111. // iIconIndex - Optional icon index, default to 0.
  1112. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1113. // wHotKey - Hot key for the link file, default to 0
  1114. // iShowCmd - Specifies how the application should be launched.
  1115. // Use a default of SW_SHOWNORMAL
  1116. //
  1117. // Returns: TRUE if successful
  1118. // FALSE if not. Call GetLastError() for more details
  1119. //
  1120. // Notes: New applications should use the CreateLinkFile() function instead
  1121. // of AddItem. This allows for friendly tooltip descriptions.
  1122. //
  1123. // The lpFileName argument should not include the .lnk extension.
  1124. // This function will add the extension.
  1125. //
  1126. // If the lpWorkingDirectory parameter is NULL, this function will
  1127. // insert the home directory environment variables
  1128. //
  1129. // If the requested group doesn't exist, it will be created.
  1130. //
  1131. // If the lpCommandLine target is located below the system root,
  1132. // the SystemRoot environment variable will be inserted into the path
  1133. //
  1134. // Here's a sample of how this function is typically called:
  1135. //
  1136. // AddItem (TEXT("Accessories"), FALSE, TEXT("Notepad"),
  1137. // TEXT("notepad.exe"), NULL, 0, NULL, 0, SW_SHOWNORMAL);
  1138. //
  1139. // This function should only be used the Windows NT team. Developers
  1140. // outside of the Windows NT team can use the IShellLink interface
  1141. // to create link files.
  1142. //
  1143. //=============================================================================
  1144. USERENVAPI
  1145. BOOL
  1146. WINAPI
  1147. AddItem%(
  1148. IN LPCTSTR% lpGroupName,
  1149. IN BOOL bCommonGroup,
  1150. IN LPCTSTR% lpFileName,
  1151. IN LPCTSTR% lpCommandLine,
  1152. IN LPCTSTR% lpIconPath,
  1153. IN INT iIconIndex,
  1154. IN LPCTSTR% lpWorkingDirectory,
  1155. IN WORD wHotKey,
  1156. IN INT iShowCmd);
  1157. //=============================================================================
  1158. //
  1159. // DeleteItem
  1160. //
  1161. // Deletes an item on the Programs portion of the Start Menu in the
  1162. // requested group.
  1163. //
  1164. // lpGroupName - Name of group
  1165. // bCommonGroup - Common or personal group
  1166. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1167. // bDeleteGroup - After deleting the link, delete the group if its empty.
  1168. //
  1169. // Returns: TRUE if successful
  1170. // FALSE if not. Call GetLastError() for more details
  1171. //
  1172. // Notes: New applications should use the DeleteLinkFile() function instead
  1173. // of DeleteItem.
  1174. //
  1175. // The lpFileName argument should not include the .lnk extension.
  1176. // This function will add the extension.
  1177. //
  1178. // Here's a sample of how this function is typically called:
  1179. //
  1180. // DeleteItem (TEXT("Accessories"), FALSE, TEXT("Notepad"), TRUE);
  1181. //
  1182. // This function should only be used the Windows NT team. Developers
  1183. // outside of the Windows NT team can use the IShellLink interface
  1184. // to create link files and DeleteFile to delete them.
  1185. //
  1186. //=============================================================================
  1187. USERENVAPI
  1188. BOOL
  1189. WINAPI
  1190. DeleteItem%(
  1191. IN LPCTSTR% lpGroupName,
  1192. IN BOOL bCommonGroup,
  1193. IN LPCTSTR% lpFileName,
  1194. IN BOOL bDeleteGroup);
  1195. //=============================================================================
  1196. //
  1197. // AddDesktopItem
  1198. //
  1199. // Creates an item on desktop. This function is very similar to AddItem()
  1200. // documented above. See that function for more information.
  1201. //
  1202. // Notes: New applications should use the CreateLinkFile() function instead
  1203. // of AddItem. This allows for friendly tooltip descriptions.
  1204. //
  1205. // This function should only be used the Windows NT team. Developers
  1206. // outside of the Windows NT team can use the IShellLink interface
  1207. // to create link files.
  1208. //
  1209. //=============================================================================
  1210. USERENVAPI
  1211. BOOL
  1212. WINAPI
  1213. AddDesktopItem%(
  1214. IN BOOL bCommonItem,
  1215. IN LPCTSTR% lpFileName,
  1216. IN LPCTSTR% lpCommandLine,
  1217. IN LPCTSTR% lpIconPath,
  1218. IN INT iIconIndex,
  1219. IN LPCTSTR% lpWorkingDirectory,
  1220. IN WORD wHotKey,
  1221. IN INT iShowCmd);
  1222. //=============================================================================
  1223. //
  1224. // DeleteDesktopItem
  1225. //
  1226. // Deletes an item from the desktop. This function is very similar to DeleteItem()
  1227. // documented above. See that function for more information.
  1228. //
  1229. // Notes: New applications should use the DeleteLinkFile() function instead
  1230. // of DeleteDesktopItem.
  1231. //
  1232. // This function should only be used the Windows NT team. Developers
  1233. // outside of the Windows NT team can use the IShellLink interface
  1234. // to create link files and DeleteFile to delete them.
  1235. //
  1236. //=============================================================================
  1237. USERENVAPI
  1238. BOOL
  1239. WINAPI
  1240. DeleteDesktopItem%(
  1241. IN BOOL bCommonItem,
  1242. IN LPCTSTR% lpFileName);
  1243. //=============================================================================
  1244. //
  1245. // CreateLinkFile
  1246. //
  1247. // Creates a link file (aka shortcut) in the requested special folder or
  1248. // subdirectory of a special folder.
  1249. //
  1250. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1251. // lpSubDirectory - Subdirectory name. See note below
  1252. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1253. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1254. // lpIconPath - Optional icon path, can be NULL.
  1255. // iIconIndex - Optional icon index, default to 0.
  1256. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1257. // wHotKey - Hot key for the link file, default to 0
  1258. // iShowCmd - Specifies how the application should be launched.
  1259. // Use a default of SW_SHOWNORMAL
  1260. // lpDescription - Friendly description of shortcut, can be NULL.
  1261. //
  1262. // Returns: TRUE if successful
  1263. // FALSE if not. Call GetLastError() for more details
  1264. //
  1265. // Notes: New applications should use this function instead of AddItem or
  1266. // AddDesktopItem. This allows for friendly tooltip descriptions.
  1267. //
  1268. // The link file name is a combination of the first three
  1269. // parameters. If a csidl is given, that special folder is
  1270. // looked up first, and then the lpSubDirectory is appended to
  1271. // it followed by the lpFileName. If csidl is equal to 0, then
  1272. // lpSubDirectory should contain the fully qualified path to the
  1273. // directory the link file is to be placed in. This allows
  1274. // for link files to be be created outside of the scope of a
  1275. // shell special folder. The csidl constants are listed in
  1276. // shlobj.h or in the Win32 documentation for SHGetSpecialFolderPath.
  1277. // Commonly used csidl's will be:
  1278. //
  1279. // CSIDL_PROGRAMS - Personal Program folder on Start Menu
  1280. // CSIDL_COMMON_PROGRAMS - Common Program folder on Start Menu
  1281. // CSIDL_DESKTOPDIRECTORY - Personal desktop folder
  1282. // CSIDL_COMMON_DESKTOPDIRECTORY - Common desktop folder
  1283. //
  1284. // The lpFileName argument should not include the .lnk extension.
  1285. // This function will add the extension.
  1286. //
  1287. // If the lpWorkingDirectory parameter is NULL, this function will
  1288. // insert home directory environment variables.
  1289. //
  1290. // If the requested subdirectory doesn't exist, it will be created.
  1291. //
  1292. // If the lpCommandLine target is located below the system root,
  1293. // the SystemRoot environment variable will be inserted into the path
  1294. //
  1295. // Here's a sample of how this function is typically called:
  1296. //
  1297. // CreateLinkFile (CSIDL_PROGRAMS, TEXT("Accessories"), TEXT("Notepad"),
  1298. // TEXT("notepad.exe"), NULL, 0, NULL, 0, SW_SHOWNORMAL,
  1299. // TEXT("A simple word processor."));
  1300. //
  1301. // This function should only be used the Windows NT team. Developers
  1302. // outside of the Windows NT team can use the IShellLink interface
  1303. // to create link files.
  1304. //
  1305. //=============================================================================
  1306. ;begin_winver_500
  1307. USERENVAPI
  1308. BOOL
  1309. WINAPI
  1310. CreateLinkFile%(
  1311. IN INT csidl,
  1312. IN LPCTSTR% lpSubDirectory,
  1313. IN LPCTSTR% lpFileName,
  1314. IN LPCTSTR% lpCommandLine,
  1315. IN LPCTSTR% lpIconPath,
  1316. IN INT iIconIndex,
  1317. IN LPCTSTR% lpWorkingDirectory,
  1318. IN WORD wHotKey,
  1319. IN INT iShowCmd,
  1320. IN LPCTSTR% lpDescription);
  1321. ;end_winver_500
  1322. //=============================================================================
  1323. //
  1324. // CreateLinkFileEx
  1325. //
  1326. // Creates a link file (aka shortcut) in the requested special folder or
  1327. // subdirectory of a special folder.
  1328. //
  1329. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1330. // lpSubDirectory - Subdirectory name. See note below
  1331. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1332. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1333. // lpIconPath - Optional icon path, can be NULL.
  1334. // iIconIndex - Optional icon index, default to 0.
  1335. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1336. // wHotKey - Hot key for the link file, default to 0
  1337. // iShowCmd - Specifies how the application should be launched.
  1338. // Use a default of SW_SHOWNORMAL
  1339. // lpDescription - Friendly description of shortcut, can be NULL.
  1340. // lpResourceModuleName - Name of the resource module. Can be NULL
  1341. // uResourceID - Resource ID for the MUI display name.
  1342. //
  1343. // Returns: TRUE if successful
  1344. // FALSE if not. Call GetLastError() for more details
  1345. //
  1346. // for additional descriptions look in the description of Createlinkfile above.
  1347. //=============================================================================
  1348. ;begin_winver_500
  1349. USERENVAPI
  1350. BOOL
  1351. WINAPI
  1352. CreateLinkFileEx%(
  1353. IN INT csidl,
  1354. IN LPCTSTR% lpSubDirectory,
  1355. IN LPCTSTR% lpFileName,
  1356. IN LPCTSTR% lpCommandLine,
  1357. IN LPCTSTR% lpIconPath,
  1358. IN INT iIconIndex,
  1359. IN LPCTSTR% lpWorkingDirectory,
  1360. IN WORD wHotKey,
  1361. IN INT iShowCmd,
  1362. IN LPCTSTR% lpDescription,
  1363. IN LPCTSTR% lpResourceModuleName,
  1364. IN UINT uResourceID);
  1365. ;end_winver_500
  1366. //=============================================================================
  1367. //
  1368. // DeleteLinkFile
  1369. //
  1370. // Deletes a link file (aka shortcut) in the requested special folder or
  1371. // subdirectory of a special folder.
  1372. //
  1373. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1374. // lpSubDirectory - Subdirectory name. See note below
  1375. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1376. // bDeleteSubDirectory - After deleting the link, delete the subdirectory if its empty.
  1377. //
  1378. // Returns: TRUE if successful
  1379. // FALSE if not. Call GetLastError() for more details
  1380. //
  1381. // Notes: New applications should use this function instead DeleteItem or
  1382. // DeleteDesktopItem.
  1383. //
  1384. // The link file name is a combination of the first three
  1385. // parameters. If a csidl is given, that special folder is
  1386. // looked up first, and then the lpSubDirectory is appended to
  1387. // it followed by the lpFileName. If csidl is equal to 0, then
  1388. // lpSubDirectory should contain the fully qualified path to the
  1389. // directory the link file is to be placed in. This allows
  1390. // for link files to be be deleted outside of the scope of a
  1391. // shell special folder. The csidl constants are listed in
  1392. // shlobj.h or in the Win32 documentation for SHGetSpecialFolderPath.
  1393. // Commonly used csidl's will be:
  1394. //
  1395. // CSIDL_PROGRAMS - Personal Program folder on Start Menu
  1396. // CSIDL_COMMON_PROGRAMS - Common Program folder on Start Menu
  1397. // CSIDL_DESKTOPDIRECTORY - Personal desktop folder
  1398. // CSIDL_COMMON_DESKTOPDIRECTORY - Common desktop folder
  1399. //
  1400. // The lpFileName argument should not include the .lnk extension.
  1401. // This function will add the extension.
  1402. //
  1403. // This function should only be used the Windows NT team. Developers
  1404. // outside of the Windows NT team can use the IShellLink interface
  1405. // to create link files and DeleteFile to delete them.
  1406. //
  1407. //=============================================================================
  1408. ;begin_winver_500
  1409. USERENVAPI
  1410. BOOL
  1411. WINAPI
  1412. DeleteLinkFile%(
  1413. IN INT csidl,
  1414. IN LPCTSTR% lpSubDirectory,
  1415. IN LPCTSTR% lpFileName,
  1416. IN BOOL bDeleteSubDirectory);
  1417. ;end_winver_500
  1418. #endif // _USERENV_NO_LINK_APIS_
  1419. //=============================================================================
  1420. //
  1421. // InitializeProfiles
  1422. //
  1423. // This function is used by GUI mode setup only and setup repair. It initializes
  1424. // the Default User and All User profiles and converts any common groups from
  1425. // Program Manager.
  1426. //
  1427. // bGuiModeSetup - Gui Mode setup or not.
  1428. //
  1429. //
  1430. // Returns: TRUE if successful
  1431. // FALSE if not. Call GetLastError() for more details
  1432. //
  1433. //=============================================================================
  1434. USERENVAPI
  1435. BOOL
  1436. WINAPI
  1437. InitializeProfiles(
  1438. IN BOOL bGuiModeSetup);
  1439. //*************************************************************
  1440. //
  1441. // CopySystemProfile()
  1442. //
  1443. // Purpose: Create the system profile information under
  1444. // ProfileList entry.
  1445. // In case of upgrade copy system profile from older
  1446. // location to new location and delete the old system
  1447. // profile
  1448. //
  1449. // Parameters:
  1450. //
  1451. // Return: TRUE if successful
  1452. // FALSE if an error occurs. Call GetLastError()
  1453. //
  1454. // Comments: This should only be called by GUI mode setup!
  1455. //
  1456. //*************************************************************
  1457. USERENVAPI
  1458. BOOL
  1459. WINAPI
  1460. CopySystemProfile(
  1461. IN BOOL bCleanInstall);
  1462. //=============================================================================
  1463. //
  1464. // DetermineProfilesLocation
  1465. //
  1466. // This function is used by winlogon when GUI mode setup is about to start.
  1467. // It sets the correct user profile location in the registry.
  1468. //
  1469. // bCleanInstall - True if setup is performing a clean install
  1470. //
  1471. // Returns: TRUE if successful
  1472. // FALSE if not. Call GetLastError() for more details
  1473. //
  1474. //=============================================================================
  1475. ;begin_winver_500
  1476. USERENVAPI
  1477. BOOL
  1478. WINAPI
  1479. DetermineProfilesLocation(
  1480. BOOL bCleanInstall);
  1481. ;end_winver_500
  1482. //=============================================================================
  1483. //
  1484. // CreateUserProfile(Ex)
  1485. //
  1486. // Creates a user profile for the given user. Used by the Win95 -> NT5
  1487. // migration code.
  1488. //
  1489. // pSid - SID of new user
  1490. // lpUserName - User name of new user
  1491. // lpUserHive - Registry hive to use (optional, can be NULL)
  1492. // lpProfileDir - Receives the user's profile directory (can be NULL)
  1493. // dwDirSize - Size of lpProfileDir
  1494. // bWin9xUpg - Flag to say whether it is win9x upgrade
  1495. //
  1496. // Returns: TRUE if successful
  1497. // FALSE if not.
  1498. //
  1499. //=============================================================================
  1500. ;begin_winver_500
  1501. USERENVAPI
  1502. BOOL
  1503. WINAPI
  1504. CreateUserProfile%(
  1505. IN PSID pSid,
  1506. IN LPCTSTR% lpUserName,
  1507. IN LPCTSTR% lpUserHive,
  1508. OUT LPTSTR% lpProfileDir,
  1509. IN DWORD dwDirSize);
  1510. USERENVAPI
  1511. BOOL
  1512. WINAPI
  1513. CreateUserProfileEx%(
  1514. IN PSID pSid,
  1515. IN LPCTSTR% lpUserName,
  1516. IN LPCTSTR% lpUserHive,
  1517. OUT LPTSTR% lpProfileDir,
  1518. IN DWORD dwDirSize,
  1519. IN BOOL bWin9xUpg);
  1520. ;end_winver_500
  1521. //=============================================================================
  1522. //
  1523. // CopyProfileDirectory(Ex)
  1524. //
  1525. // Multi-threaded user profile coping algorithm.
  1526. //
  1527. // lpSourceDir - Source directory
  1528. // lpDestinationDir - Destination directory
  1529. // dwFlags - Flags (defined below)
  1530. // ftDelRefTime - Reference time used when deleted extra files
  1531. // in a CPD_SYNCHRONIZE operation
  1532. // lpExclusionList - List of directories to exclude when copying the
  1533. // profile
  1534. //
  1535. // Returns: TRUE if successful
  1536. // FALSE if not.
  1537. //
  1538. // Notes: When CPD_SYNCHRONIZE is used to copy a profile from one
  1539. // location to another, all the files / directories are copied first
  1540. // and then extra files in the target directory are deleted. In the
  1541. // case of 2 machines using the same roaming profile, it doesn't make
  1542. // sense to delete the extra files everytime. If the CPD_USEDELREFTIME
  1543. // flag is set, then before deleting a file or directory, the
  1544. // time on that file or directory is compared with ftDelRefTime.
  1545. // If the time is newer, the file / directory is not deleted because
  1546. // it is probably a new file from a different machine. If the
  1547. // time is older, the file / directory is deleted.
  1548. //
  1549. // CopyProfileDirectoryEx can also exclude certain directories
  1550. // from the copy. If the CPD_USEEXCLUSIONLIST flag is set and
  1551. // lpExclusionList is non-null, the specified directories (and
  1552. // their children) will be excuded from the copy. The format
  1553. // of this parameter is a semi-colon separated list of directories
  1554. // relative to the root of the source profile. For example:
  1555. //
  1556. // Temporary Internet Files;Temp;Foo\Bar
  1557. //
  1558. //=============================================================================
  1559. //
  1560. // Flags for CopyProfileDirectory(Ex)
  1561. //
  1562. #define CPD_FORCECOPY 0x00000001 // Ignore time stamps and always copy the file
  1563. #define CPD_IGNORECOPYERRORS 0x00000002 // Ignore errors and keep going
  1564. #define CPD_IGNOREHIVE 0x00000004 // Don't copy registry hive
  1565. #define CPD_WIN95HIVE 0x00000008 // Looking for Win 9x registry hive instead of NT registry hive
  1566. #define CPD_COPYIFDIFFERENT 0x00000010 // If a file exists in both src and dest with different time stamps, always copy it.
  1567. #define CPD_SYNCHRONIZE 0x00000020 // Make dest directory structure indentical to src directory structure (delete extra files and directories)
  1568. #define CPD_SLOWCOPY 0x00000040 // Don't use multiple thread. Copy one file at a time.
  1569. #define CPD_SHOWSTATUS 0x00000080 // Show progress dialog
  1570. #define CPD_CREATETITLE 0x00000100 // Change progress dialog title to Creating... rather than Copying...
  1571. #define CPD_COPYHIVEONLY 0x00000200 // Only copy the hive, no other files
  1572. #define CPD_USEDELREFTIME 0x00000400 // Use ftDelRefTime parameter in CopyProfileDirectoryEx
  1573. #define CPD_USEEXCLUSIONLIST 0x00000800 // Use lpExclusionList parameter in CopyProfileDirectoryEx
  1574. #define CPD_SYSTEMFILES 0x00001000 // Only copy files and directories with the system file attribute set
  1575. #define CPD_DELDESTEXCLUSIONS 0x00002000 // If a directory that is excluded in the source already exists in the destination, delete it
  1576. #define CPD_NONENCRYPTEDONLY 0x00004000 // Copy only non encrypted files
  1577. #define CPD_IGNORESECURITY 0x00008000 // Ignore the ACLs etc. on the source files
  1578. #define CPD_NOERRORUI 0x00010000 // Do not show the UI if error occurs
  1579. #define CPD_SYSTEMDIRSONLY 0x00020000 // Only copy directories with the system file attribute set
  1580. #define CPD_IGNOREENCRYPTEDFILES 0x00040000 // Ignore Encrypted files
  1581. #define CPD_IGNORELONGFILENAMES 0x00080000 // Ignore files with long file names
  1582. #define CPD_USETMPHIVEFILE 0x00100000 // user hive is still loaded
  1583. USERENVAPI
  1584. BOOL
  1585. WINAPI
  1586. CopyProfileDirectory%(
  1587. IN LPCTSTR% lpSourceDir,
  1588. IN LPCTSTR% lpDestinationDir,
  1589. IN DWORD dwFlags);
  1590. USERENVAPI
  1591. BOOL
  1592. WINAPI
  1593. CopyProfileDirectoryEx%(
  1594. IN LPCTSTR% lpSourceDir,
  1595. IN LPCTSTR% lpDestinationDir,
  1596. IN DWORD dwFlags,
  1597. IN LPFILETIME ftDelRefTime,
  1598. IN LPCTSTR% lpExclusionList);
  1599. //=============================================================================
  1600. //
  1601. // MigrateNT4ToNT5
  1602. //
  1603. // Migrates a user's profile from NT4 to NT5. This function should
  1604. // only be called by shmgrate.exe
  1605. //
  1606. // Returns: TRUE if successful
  1607. // FALSE if not.
  1608. //
  1609. //=============================================================================
  1610. ;begin_winver_500
  1611. USERENVAPI
  1612. BOOL
  1613. WINAPI
  1614. MigrateNT4ToNT5();
  1615. ;end_winver_500
  1616. //=============================================================================
  1617. //
  1618. // ResetUserSpecialFolderPaths
  1619. //
  1620. // Sets all of the user special folder paths back to their defaults
  1621. //
  1622. // Returns: TRUE if successful
  1623. // FALSE if not.
  1624. //
  1625. //=============================================================================
  1626. ;begin_winver_500
  1627. USERENVAPI
  1628. BOOL
  1629. WINAPI
  1630. ResetUserSpecialFolderPaths();
  1631. ;end_winver_500
  1632. //=============================================================================
  1633. //
  1634. // GetSystemTempDirectory
  1635. //
  1636. // Gets the system wide temp directory in short form
  1637. //
  1638. // Returns: TRUE if successful
  1639. // FALSE if not.
  1640. //
  1641. //=============================================================================
  1642. USERENVAPI
  1643. BOOL
  1644. WINAPI
  1645. GetSystemTempDirectory%(
  1646. OUT LPTSTR% lpDir,
  1647. IN OUT LPDWORD lpcchSize);
  1648. //=============================================================================
  1649. //
  1650. // ApplySystemPolicy
  1651. //
  1652. //
  1653. // Entry point for Windows NT4 System Policy.
  1654. //
  1655. // dwFlags - Flags
  1656. // hToken - User's token
  1657. // hKeyCurrentUser - Registry to the root of the user's hive
  1658. // lpUserName - User's name
  1659. // lpPolicyPath - Path to the policy file (ntconfig.pol). Can be NULL.
  1660. // lpServerName - Domain controller name used for group
  1661. // membership look up. Can be NULL.
  1662. //
  1663. //
  1664. // Returns: TRUE if successful
  1665. // FALSE if not
  1666. //
  1667. //=============================================================================
  1668. ;begin_winver_500
  1669. #define SP_FLAG_APPLY_MACHINE_POLICY 0x00000001
  1670. #define SP_FLAG_APPLY_USER_POLICY 0x00000002
  1671. USERENVAPI
  1672. BOOL
  1673. WINAPI
  1674. ApplySystemPolicy%(
  1675. IN DWORD dwFlags,
  1676. IN HANDLE hToken,
  1677. IN HKEY hKeyCurrentUser,
  1678. IN LPCTSTR% lpUserName,
  1679. IN LPCTSTR% lpPolicyPath,
  1680. IN LPCTSTR% lpServerName);
  1681. ;end_winver_500
  1682. ;begin_winver_500
  1683. //=============================================================================
  1684. //
  1685. // Data types and data structures for foreground policy refresh info.
  1686. //
  1687. //=============================================================================
  1688. typedef enum _tagFgPolicyRefreshReason
  1689. {
  1690. GP_ReasonUnknown = 0,
  1691. GP_ReasonFirstPolicy,
  1692. GP_ReasonCSERequiresSync,
  1693. GP_ReasonCSESyncError,
  1694. GP_ReasonSyncForced,
  1695. GP_ReasonSyncPolicy,
  1696. GP_ReasonNonCachedCredentials,
  1697. GP_ReasonSKU
  1698. } FgPolicyRefreshReason;
  1699. typedef enum _tagFgPolicyRefreshMode
  1700. {
  1701. GP_ModeUnknown = 0,
  1702. GP_ModeSyncForeground,
  1703. GP_ModeAsyncForeground,
  1704. } FgPolicyRefreshMode;
  1705. typedef struct _tagFgPolicyRefreshInfo
  1706. {
  1707. FgPolicyRefreshReason reason;
  1708. FgPolicyRefreshMode mode;
  1709. } FgPolicyRefreshInfo, *LPFgPolicyRefreshInfo;
  1710. //=============================================================================
  1711. //
  1712. // SetNextFgPolicyRefreshInfo
  1713. //
  1714. // Sets information about the next foreground policy
  1715. //
  1716. // szUserSid - user's SID for user's info, 0 for machine info
  1717. // info - FgPolicyRefreshInfo structure with the reason and mode info
  1718. //
  1719. // Returns: WIN32 error code
  1720. //
  1721. //=============================================================================
  1722. USERENVAPI
  1723. DWORD
  1724. WINAPI
  1725. SetNextFgPolicyRefreshInfo( LPWSTR szUserSid,
  1726. FgPolicyRefreshInfo info );
  1727. //=============================================================================
  1728. //
  1729. // GetPreviousFgPolicyRefreshInfo
  1730. //
  1731. // Gets information about the previous foreground policy
  1732. //
  1733. // szUserSid - user's SID for user's info, 0 for machine info
  1734. // pInfo - pointer to the FgPolicyRefreshInfo structure; returns the info
  1735. //
  1736. // Returns: WIN32 error code
  1737. //
  1738. //=============================================================================
  1739. USERENVAPI
  1740. DWORD
  1741. WINAPI
  1742. GetPreviousFgPolicyRefreshInfo( LPWSTR szUserSid,
  1743. FgPolicyRefreshInfo* pInfo );
  1744. //=============================================================================
  1745. //
  1746. // GetNextFgPolicyRefreshInfo
  1747. //
  1748. // Gets information about the previous foreground policy
  1749. //
  1750. // szUserSid - user's SID for user's info, 0 for machine info
  1751. // pInfo - pointer to the FgPolicyRefreshInfo structure; returns info
  1752. //
  1753. // Returns: WIN32 error code
  1754. //
  1755. //=============================================================================
  1756. USERENVAPI
  1757. DWORD
  1758. WINAPI
  1759. GetNextFgPolicyRefreshInfo( LPWSTR szUserSid,
  1760. FgPolicyRefreshInfo* pInfo );
  1761. //=============================================================================
  1762. //
  1763. // ForceSyncFgPolicy
  1764. //
  1765. // Forces the next foreground policy to be Synchronous
  1766. //
  1767. // szUserSid - user's SID for user's info, 0 for machine info
  1768. //
  1769. // Returns: WIN32 error code
  1770. //
  1771. //=============================================================================
  1772. USERENVAPI
  1773. DWORD
  1774. WINAPI
  1775. ForceSyncFgPolicy( LPWSTR szUserSid );
  1776. //=============================================================================
  1777. //
  1778. // WaitForUserPolicyForegroundProcessing
  1779. //
  1780. // Blocks the caller until the user foreground policy is finished
  1781. //
  1782. // Returns: WIN32 error code
  1783. //
  1784. //=============================================================================
  1785. USERENVAPI
  1786. DWORD
  1787. WINAPI
  1788. WaitForUserPolicyForegroundProcessing();
  1789. //=============================================================================
  1790. //
  1791. // WaitForMachinePolicyForegroundProcessing
  1792. //
  1793. // Blocks the caller until the machine foreground policy is finished
  1794. //
  1795. // Returns: WIN32 error code
  1796. //
  1797. //=============================================================================
  1798. USERENVAPI
  1799. DWORD
  1800. WINAPI
  1801. WaitForMachinePolicyForegroundProcessing();
  1802. //=============================================================================
  1803. //
  1804. // IsSyncForegroundPolicyRefresh
  1805. //
  1806. // Called during foreground refresh to determine whether the refresh is sync or
  1807. // async
  1808. //
  1809. // bMachine - user or machine
  1810. // hToken - User or machine token
  1811. //
  1812. // Returns: TRUE if foreground policy should be applied synchronously,
  1813. // FALSE otherwise
  1814. //
  1815. //=============================================================================
  1816. USERENVAPI
  1817. BOOL
  1818. WINAPI
  1819. IsSyncForegroundPolicyRefresh( BOOL bMachine,
  1820. HANDLE hToken );
  1821. ;end_winver_500
  1822. //=============================================================================
  1823. //
  1824. // ApplyGroupPolicy
  1825. //
  1826. //
  1827. // Entry point for Group Policy. Causes either machine or user
  1828. // policy to be applied.
  1829. //
  1830. // dwFlags - Flags defined below
  1831. // hToken - User or machine token
  1832. // hEvent - Handle to an event which causes the policy thread to
  1833. // terminate when signaled.
  1834. // hKeyRoot - Registry to the root of the correspond hive
  1835. // eg: HKLM or HKCU for the user that matches hToken
  1836. // pStatusCallback - Callback function for displaying status messages
  1837. //
  1838. //
  1839. // Returns: If GP_BACKGROUND_REFRESH is set, a thread handle
  1840. // the process can wait until after signaling for policy
  1841. // to stop. If GPT_BACKGROUND_REFRESH is not set, the
  1842. // return value is 1.
  1843. //
  1844. // In the case of failure, NULL will be returned.
  1845. //
  1846. //=============================================================================
  1847. ;begin_winver_500
  1848. //
  1849. // Flags to the ApplyGroupPolicy() function
  1850. //
  1851. #define GP_MACHINE 0x00000001 // Process for machine (vs user)
  1852. #define GP_BACKGROUND_REFRESH 0x00000002 // Use background thread
  1853. #define GP_APPLY_DS_POLICY 0x00000004 // Apply policy from the DS also
  1854. #define GP_ASYNC_FOREGROUND 0x00000008 // don't wait on network services
  1855. //
  1856. // Flags set by ApplyGroupPolicy() function (do not pass these in)
  1857. //
  1858. #define GP_BACKGROUND_THREAD 0x00010000 // Background thread processing
  1859. #define GP_REGPOLICY_CPANEL 0x00020000 // Something changed in the CP settings
  1860. #define GP_SLOW_LINK 0x00040000 // Slow network connection
  1861. #define GP_VERBOSE 0x00080000 // Verbose output to eventlog
  1862. #define GP_FORCED_REFRESH 0x00100000 // Forced Refresh
  1863. // The 2 bit values were briefly used.
  1864. #define GP_PLANMODE 0x00800000 // Planning mode flag
  1865. USERENVAPI
  1866. HANDLE
  1867. WINAPI
  1868. ApplyGroupPolicy(
  1869. IN DWORD dwFlags,
  1870. IN HANDLE hToken,
  1871. IN HANDLE hEvent,
  1872. IN HKEY hKeyRoot,
  1873. IN PFNSTATUSMESSAGECALLBACK pStatusCallback);
  1874. //=============================================================================
  1875. //
  1876. // GenerateRsopPolicy
  1877. //
  1878. // Generates planning mode Rsop policy for specified target
  1879. //
  1880. // dwFlags - Processing flags
  1881. // bstrMachName - Target computer name
  1882. // bstrNewMachSOM - New machine domain or OU
  1883. // psaMachSecGroups - New machine security groups
  1884. // bstrUserName - Target user name
  1885. // psaUserSecGroups - New user security groups
  1886. // bstrSite - Site of target computer
  1887. // pwszNameSpace - Namespace to write Rsop data
  1888. // pProgress - Progress indicator info
  1889. // pMachGpoFilter - GPO Filters that pass in machine processing
  1890. // pUserGpoFilter - GPO Filters that pass in user processing
  1891. //
  1892. // Return: True if successful, False otherwise
  1893. //
  1894. //=============================================================================
  1895. USERENVAPI
  1896. BOOL
  1897. WINAPI
  1898. GenerateRsopPolicy(
  1899. IN DWORD dwFlags,
  1900. IN BSTR bstrMachName,
  1901. IN BSTR bstrNewMachSOM,
  1902. IN SAFEARRAY *psaMachSecGroups,
  1903. IN BSTR bstrUserName,
  1904. IN BSTR bstrNewUserSOM,
  1905. IN SAFEARRAY *psaUserSecGroups,
  1906. IN BSTR bstrSite,
  1907. IN WCHAR *pwszNameSpace,
  1908. IN LPVOID pProgress,
  1909. IN LPVOID pMachGpoFilter,
  1910. IN LPVOID pUserGpoFilter);
  1911. ;end_winver_500
  1912. //=============================================================================
  1913. //
  1914. // ShutdownGPOProcessing()
  1915. //
  1916. // Entry point for aborting GPO processing
  1917. //
  1918. // bMachine - Shutdown machine or user processing ?
  1919. //
  1920. // Returns: void
  1921. //
  1922. //=============================================================================
  1923. ;begin_winver_500
  1924. USERENVAPI
  1925. void
  1926. WINAPI
  1927. ShutdownGPOProcessing(
  1928. IN BOOL bMachine);
  1929. ;end_winver_500
  1930. //=============================================================================
  1931. //
  1932. // PingComputer()
  1933. //
  1934. // Pings the specified computer
  1935. //
  1936. // ipaddr - IP address of the computer in unsigned long form
  1937. // ulSpeed - Data transfer rate
  1938. //
  1939. // Notes: For fast connections (eg: LAN), it isn't possible
  1940. // to get accurate transfer rates since the response
  1941. // time from the computer is less than 10ms. In
  1942. // this case, the function returns ERROR_SUCCESS
  1943. // and ulSpeed is set to 0. If the function returns
  1944. // ERROR_SUCCESS and the ulSpeed argument is non-zero
  1945. // the connections is slower
  1946. //
  1947. // Returns: ERROR_SUCCESS if successful
  1948. // Win32 error code if not
  1949. //
  1950. //=============================================================================
  1951. ;begin_winver_500
  1952. USERENVAPI
  1953. DWORD
  1954. WINAPI
  1955. PingComputer(
  1956. IN ULONG ipaddr,
  1957. OUT ULONG *ulSpeed);
  1958. ;end_winver_500
  1959. //=============================================================================
  1960. //
  1961. // InitializeUserProfile()
  1962. //
  1963. // Called by winlogon to initialize userenv.dll for loading/unloading user
  1964. // profiles.
  1965. //
  1966. // Returns: fvoid
  1967. //
  1968. //=============================================================================
  1969. ;begin_winver_500
  1970. USERENVAPI
  1971. void
  1972. WINAPI
  1973. InitializeUserProfile();
  1974. ;end_winver_500
  1975. //=============================================================================
  1976. //
  1977. // EnterUserProfileLock()
  1978. //
  1979. // Get the user profile synchronization lock for a user
  1980. //
  1981. // Returns: HRESULT
  1982. //
  1983. //=============================================================================
  1984. ;begin_winver_500
  1985. USERENVAPI
  1986. DWORD
  1987. WINAPI
  1988. EnterUserProfileLock(LPTSTR pSid);
  1989. ;end_winver_500
  1990. //=============================================================================
  1991. //
  1992. // LeaveUserProfileLock()
  1993. //
  1994. // Release the user profile synchronization lock for a user
  1995. //
  1996. // Returns: HRESULT
  1997. //
  1998. //=============================================================================
  1999. ;begin_winver_500
  2000. USERENVAPI
  2001. DWORD
  2002. WINAPI
  2003. LeaveUserProfileLock(LPTSTR pSid);
  2004. ;end_winver_500
  2005. //*************************************************************************
  2006. //
  2007. // SecureUserProfiles()
  2008. //
  2009. // Routine Description :
  2010. // This function secures user profiles during FAT->NTFS conversion.
  2011. // The function loops through all profiles registered under current
  2012. // OS and sets the security for the corresponding profile directory
  2013. // and nested subdirs. Assumption is the function will be called
  2014. // only during FAT->NTFS conversion.
  2015. //
  2016. // Arguments :
  2017. // None.
  2018. //
  2019. // Return Value :
  2020. // None.
  2021. //
  2022. // History: Date Author Comment
  2023. // 8/8/00 santanuc Created
  2024. //
  2025. //*************************************************************************
  2026. ;begin_winver_500
  2027. USERENVAPI
  2028. void
  2029. WINAPI
  2030. SecureUserProfiles(void);
  2031. ;end_winver_500
  2032. //*************************************************************************
  2033. //
  2034. // CheckAccessForPolicyGeneration()
  2035. //
  2036. // Routine Description :
  2037. // This function checks whether the given user represented by the token
  2038. // has access to generate rsop data (planning or logging)
  2039. //
  2040. // Arguments :
  2041. // hToken - Token of the user
  2042. // szContainer - Container for which access needs to be checked.
  2043. // Should be OU or domain container
  2044. // szDomain - Domaindns where the container exists
  2045. // bLogging - True if the rsop data is to be genearated for
  2046. // logging mode
  2047. // pbAccessGranted - Access Granted or not
  2048. //
  2049. //
  2050. // Return Value :
  2051. // ERROR_SUCCESS on success. Appropriate error code otherwise
  2052. //
  2053. //*************************************************************************
  2054. ;begin_winver_500
  2055. USERENVAPI
  2056. DWORD
  2057. WINAPI
  2058. CheckAccessForPolicyGeneration( HANDLE hToken,
  2059. LPCWSTR szContainer,
  2060. LPWSTR szDomain,
  2061. BOOL bLogging,
  2062. BOOL* pbAccessGranted);
  2063. ;end_winver_500
  2064. //*************************************************************************
  2065. //
  2066. // GetGroupPolicyNetworkName()
  2067. //
  2068. // Routine Description :
  2069. // This function returns the name of the network from which policy
  2070. // was applied.
  2071. //
  2072. // Arguments :
  2073. // szNetworkName - unicode string buffer representing the network name
  2074. // pdwByteCount - size in bytes of the unicode string buffer
  2075. //
  2076. // Return Value :
  2077. // ERROR_SUCCESS if successful, error code otherwise.
  2078. //
  2079. //*************************************************************************
  2080. ;begin_winver_500
  2081. USERENVAPI
  2082. DWORD
  2083. WINAPI
  2084. GetGroupPolicyNetworkName( LPWSTR szNetworkName, LPDWORD pdwByteCount );
  2085. ;end_winver_500
  2086. //*************************************************************
  2087. //
  2088. // GetUserAppDataPath()
  2089. //
  2090. // Purpose: Returns the path for user's Appdata.
  2091. //
  2092. // Parameters: hToken - User's token
  2093. // lpFolderPath - Output buffer
  2094. //
  2095. // Return: ERROR_SUCCESS if successful
  2096. // otherwise the error code
  2097. //
  2098. // Comments: If error occurs then lpFolderPath set to empty.
  2099. // Used by Crypto guys to avoid calling SHGetFolderPath.
  2100. //
  2101. //*************************************************************
  2102. ;begin_winver_500
  2103. USERENVAPI
  2104. DWORD
  2105. WINAPI
  2106. GetUserAppDataPath%(
  2107. IN HANDLE hToken,
  2108. IN BOOL fLocalAppData,
  2109. OUT LPTSTR% lpFolderPath
  2110. );
  2111. ;end_winver_500
  2112. //=============================================================================
  2113. //
  2114. // GetUserProfileDirFromSid
  2115. //
  2116. // Returns the path to the root of the requested user's profile
  2117. //
  2118. // pSid - User's SID returned from LookupAccountName()
  2119. // lpProfileDir - Receives the path
  2120. // lpcchSize - Size of lpProfileDir
  2121. //
  2122. // Returns: TRUE if successful
  2123. // FALSE if not. Call GetLastError() for more details
  2124. //
  2125. // Note: If lpProfileDir is not large enough, the function will fail,
  2126. // and lpcchSize will contain the necessary buffer size.
  2127. //
  2128. // Example return value: C:\Documents and Settings\Joe
  2129. //
  2130. //=============================================================================
  2131. ;begin_winver_500
  2132. USERENVAPI
  2133. BOOL
  2134. WINAPI
  2135. GetUserProfileDirFromSid%(
  2136. IN PSID pSid,
  2137. OUT LPTSTR% lpProfileDir,
  2138. IN OUT LPDWORD lpcchSize);
  2139. ;end_winver_500
  2140. //=============================================================================
  2141. //
  2142. // CheckXForestLogon()
  2143. //
  2144. // Purpose: Check if the user is logged on to a different forest, if yes, we
  2145. // should disable roaming user profile for the user because of
  2146. // protential security risks. Administrator can set a policy
  2147. // "AllowX-ForestPolicy-and-RUP" to disable this check.
  2148. //
  2149. // Parameters:
  2150. // hTokenUser - user's token
  2151. //
  2152. // Return: S_OK on not x-forest logon, S_FALSE on x-forest logon,
  2153. // else for failure
  2154. //
  2155. // Comments:
  2156. //
  2157. // History: Date Author Comment
  2158. // 05/08/2002 mingzhu Created
  2159. //
  2160. //=============================================================================
  2161. ;begin_winver_500
  2162. USERENVAPI
  2163. HRESULT
  2164. WINAPI
  2165. CheckXForestLogon(IN HANDLE hTokenUser);
  2166. ;end_winver_500
  2167. ;end_internal
  2168. ;begin_both
  2169. #ifdef __cplusplus
  2170. }
  2171. #endif
  2172. ;end_both
  2173. #endif // _INC_USERENV
  2174. #endif // _INC_USERENVP ;internal