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.

2469 lines
81 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-1999
  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=ntdev,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 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 link list returned from GetGPOList
  625. //
  626. // pGPOList - Pointer to the link 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 listof 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 backwards compatibility 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 on.
  701. // policies applied in background.
  702. // NoGPOListChanges REG_DWORD True, if extension does not have to be called when
  703. // there are no changes between cached can 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. typedef UINT_PTR ASYNCCOMPLETIONHANDLE;
  747. typedef DWORD (*PFNSTATUSMESSAGECALLBACK)(BOOL bVerbose, LPWSTR lpMessage);
  748. typedef DWORD(*PFNPROCESSGROUPPOLICY)(
  749. IN DWORD dwFlags, // GPO_INFO_FLAGS
  750. IN HANDLE hToken, // User or machine token
  751. IN HKEY hKeyRoot, // Root of registry
  752. IN PGROUP_POLICY_OBJECT pDeletedGPOList, // Linked list of deleted GPOs
  753. IN PGROUP_POLICY_OBJECT pChangedGPOList, // Linked list of changed GPOs
  754. IN ASYNCCOMPLETIONHANDLE pHandle, // For asynchronous completion
  755. IN BOOL *pbAbort, // If true, then abort GPO processing
  756. IN PFNSTATUSMESSAGECALLBACK pStatusCallback); // Callback function for displaying status messages
  757. // Note, this can be NULL
  758. typedef DWORD(*PFNPROCESSGROUPPOLICYEX)(
  759. IN DWORD dwFlags, // GPO_INFO_FLAGS
  760. IN HANDLE hToken, // User or machine token
  761. IN HKEY hKeyRoot, // Root of registry
  762. IN PGROUP_POLICY_OBJECT pDeletedGPOList, // Linked list of deleted GPOs
  763. IN PGROUP_POLICY_OBJECT pChangedGPOList, // Linked list of changed GPOs
  764. IN ASYNCCOMPLETIONHANDLE pHandle, // For asynchronous completion
  765. IN BOOL *pbAbort, // If true, then abort GPO processing
  766. IN PFNSTATUSMESSAGECALLBACK pStatusCallback, // Callback function for displaying status messages
  767. // Note, this can be NULL
  768. IN IWbemServices *pWbemServices, // Pointer to namespace to log diagnostic mode data
  769. // Note, this will be NULL when Rsop logging is disabled
  770. OUT HRESULT *pRsopStatus); // RSOP Logging succeeded or not.
  771. typedef PVOID PRSOPTOKEN;
  772. typedef struct _RSOP_TARGET {
  773. WCHAR * pwszAccountName; // Account name
  774. WCHAR * pwszNewSOM; // New domain or OU location for account
  775. SAFEARRAY * psaSecurityGroups; // New security groups
  776. PRSOPTOKEN pRsopToken; // Rsop token for use with Rsop security Api's
  777. PGROUP_POLICY_OBJECT pGPOList; // Linked list of GPOs
  778. IWbemServices * pWbemServices; // Pointer to namespace to log planning mode data
  779. } RSOP_TARGET, *PRSOP_TARGET;
  780. typedef DWORD(*PFNGENERATEGROUPPOLICY)(
  781. IN DWORD dwFlags, // GPO_INFO_FLAGS
  782. IN BOOL *pbAbort, // If true, then abort GPO processing
  783. IN WCHAR *pwszSite, // Site the target computer is in
  784. IN PRSOP_TARGET pComputerTarget, // Computer target info, can be null
  785. IN PRSOP_TARGET pUserTarget ); // User target info, can be null
  786. //
  787. // GUID that identifies the registry extension
  788. //
  789. #define REGISTRY_EXTENSION_GUID { 0x35378EAC, 0x683F, 0x11D2, 0xA8, 0x9A, 0x00, 0xC0, 0x4F, 0xBB, 0xCF, 0xA2 }
  790. ;end_winver_500
  791. //=============================================================================
  792. //
  793. // Group Policy Object client side asynchronous extension processing
  794. //
  795. // extensionId - Unique guid identifying the extension
  796. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  797. // ProcessGroupPolicy call
  798. // dwStatus - Completion status of asynchronous processing
  799. //
  800. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  801. // function completed successfully. Otherwise it indicates that the function failed.
  802. //
  803. //=============================================================================
  804. ;begin_winver_500
  805. typedef GUID *REFGPEXTENSIONID;
  806. USERENVAPI
  807. DWORD
  808. WINAPI
  809. ProcessGroupPolicyCompleted(
  810. IN REFGPEXTENSIONID extensionId,
  811. IN ASYNCCOMPLETIONHANDLE pAsyncHandle,
  812. IN DWORD dwStatus);
  813. ;end_winver_500
  814. //=============================================================================
  815. //
  816. // Group Policy Object client side asynchronous extension processing
  817. //
  818. // extensionId - Unique guid identifying the extension
  819. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  820. // ProcessGroupPolicy call
  821. // dwStatus - Completion status of asynchronous processing
  822. // RsopStatus - RSoP Logging status
  823. //
  824. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  825. // function completed successfully. Otherwise it indicates that the function failed.
  826. //
  827. //=============================================================================
  828. ;begin_winver_500
  829. USERENVAPI
  830. DWORD
  831. WINAPI
  832. ProcessGroupPolicyCompletedEx(
  833. IN REFGPEXTENSIONID extensionId,
  834. IN ASYNCCOMPLETIONHANDLE pAsyncHandle,
  835. IN DWORD dwStatus,
  836. IN HRESULT RsopStatus);
  837. ;end_winver_500
  838. //=============================================================================
  839. //
  840. // Function: RsopAccessCheckByType
  841. //
  842. // Description: Determines whether the security descriptor pointed to by pSecurityDescriptor
  843. // grants the set of access rights specified in dwDesiredAccessMask
  844. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  845. //
  846. // pSecurityDescriptor - Security Descriptor on the object
  847. // pPrincipalSelfSid - Principal Sid
  848. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  849. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  850. // pObjectTypeList - Object Type List
  851. // ObjectTypeListLength - Object Type List Length
  852. // pGenericMapping - Generic Mapping
  853. // pPrivilegeSet - privilege set
  854. // pdwPrivilegeSetLength- privilege set length
  855. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  856. // the mask of standard and specific rights granted.
  857. // If pbAccessStatus is false, it is set to 0.
  858. // On failure, it is not modified.
  859. // pbAccessStatus - On success, indicates wether the requested set
  860. // of access rights was granted.
  861. // On failure, it is not modified
  862. //
  863. // Returns S_OK on success or appropriate error code.
  864. // For additional details, look at the documentation of AccessCheckByType
  865. //=============================================================================
  866. ;begin_winver_500
  867. USERENVAPI
  868. HRESULT
  869. WINAPI
  870. RsopAccessCheckByType(
  871. IN PSECURITY_DESCRIPTOR pSecurityDescriptor,
  872. IN PSID pPrincipalSelfSid,
  873. IN PRSOPTOKEN pRsopToken,
  874. IN DWORD dwDesiredAccessMask,
  875. IN POBJECT_TYPE_LIST pObjectTypeList,
  876. IN DWORD ObjectTypeListLength,
  877. IN PGENERIC_MAPPING pGenericMapping,
  878. IN PPRIVILEGE_SET pPrivilegeSet,
  879. IN LPDWORD pdwPrivilegeSetLength,
  880. OUT LPDWORD pdwGrantedAccessMask,
  881. OUT LPBOOL pbAccessStatus);
  882. ;end_winver_500
  883. //=============================================================================
  884. //
  885. // Function: RsopFileAccessCheck
  886. //
  887. // Description: Determines whether the security descriptor on the file grants the set of file access
  888. // rights specified in dwDesiredAccessMask
  889. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  890. //
  891. // pszFileName - Name of an existing filename
  892. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  893. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  894. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  895. // the mask of standard and specific rights granted.
  896. // If pbAccessStatus is false, it is set to 0.
  897. // On failure, it is not modified.
  898. // pbAccessStatus - On success, indicates wether the requested set
  899. // of access rights was granted.
  900. // On failure, it is not modified
  901. //
  902. // Returns S_OK on success or appropriate error code
  903. //=============================================================================
  904. ;begin_winver_500
  905. USERENVAPI
  906. HRESULT
  907. WINAPI
  908. RsopFileAccessCheck(
  909. IN LPTSTR pszFileName,
  910. IN PRSOPTOKEN pRsopToken,
  911. IN DWORD dwDesiredAccessMask,
  912. OUT LPDWORD pdwGrantedAccessMask,
  913. OUT LPBOOL pbAccessStatus);
  914. ;end_winver_500
  915. typedef enum _SETTINGSTATUS
  916. {
  917. RSOPUnspecified = 0,
  918. RSOPApplied,
  919. RSOPIgnored,
  920. RSOPFailed,
  921. RSOPSubsettingFailed
  922. } SETTINGSTATUS;
  923. //=============================================================================
  924. //
  925. // POLICYSETTINGSTATUSINFO
  926. //
  927. // Describes the instance of RSOP_PolicySettingStatus
  928. //
  929. // szKey - OPTIONAL, if NULL, the key is generated on the fly
  930. // szEventSource - name of the source generation event log messages
  931. // szEventLogName - name of the event log database where the messages are logged
  932. // dwEventID - event log message ID
  933. // status - status of the policy setting
  934. // timeLogged - time at which the event log message was logged
  935. //
  936. //=============================================================================
  937. typedef struct _POLICYSETTINGSTATUSINFO
  938. {
  939. LPWSTR szKey;
  940. LPWSTR szEventSource;
  941. LPWSTR szEventLogName;
  942. DWORD dwEventID;
  943. DWORD dwErrorCode;
  944. SETTINGSTATUS status;
  945. SYSTEMTIME timeLogged;
  946. } POLICYSETTINGSTATUSINFO, *LPPOLICYSETTINGSTATUSINFO;
  947. //=============================================================================
  948. //
  949. // RsopSetPolicySettingStatus
  950. //
  951. // Creates an instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  952. // and links RSOP_PolicySettingStatus to RSOP_PolicySetting
  953. //
  954. // dwFlags - flags
  955. // pServices - RSOP namespace
  956. // pSettingInstance - instance of RSOP_PolicySetting or its children
  957. // nInfo - number of PolicySettingStatusInfo
  958. // pStatus - array of PolicySettingStatusInfo
  959. //
  960. // Return: S_OK if successful, HRESULT otherwise
  961. //
  962. //=============================================================================
  963. USERENVAPI
  964. HRESULT
  965. WINAPI
  966. RsopSetPolicySettingStatus( DWORD dwFlags,
  967. IWbemServices* pServices,
  968. IWbemClassObject* pSettingInstance,
  969. DWORD nInfo,
  970. POLICYSETTINGSTATUSINFO* pStatus );
  971. //=============================================================================
  972. //
  973. // RsopResetPolicySettingStatus
  974. //
  975. // Unlinks RSOP_PolicySettingStatus from RSOP_PolicySetting,
  976. // deletes the instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  977. // and optionally deletes the instance of RSOP_PolicySetting
  978. //
  979. // dwFlags - flags
  980. // pServices - RSOP namespace
  981. // pSettingInstance - instance of RSOP_PolicySetting or its children
  982. //
  983. // Return: S_OK if successful, HRESULT otherwise
  984. //
  985. //=============================================================================
  986. USERENVAPI
  987. HRESULT
  988. WINAPI
  989. RsopResetPolicySettingStatus( DWORD dwFlags,
  990. IWbemServices* pServices,
  991. IWbemClassObject* pSettingInstance );
  992. //=============================================================================
  993. //
  994. // Flags for RSoP WMI providers
  995. //
  996. //=============================================================================
  997. // planning mode provider flags
  998. #define FLAG_NO_GPO_FILTER 0x80000000 // GPOs are not filtered, implies FLAG_NO_CSE_INVOKE
  999. #define FLAG_NO_CSE_INVOKE 0x40000000 // only GP processing done for planning mode
  1000. #define FLAG_ASSUME_SLOW_LINK 0x20000000 // planning mode RSoP assumes slow link
  1001. #define FLAG_LOOPBACK_MERGE 0x10000000 // planning mode RSoP assumes merge loop back
  1002. #define FLAG_LOOPBACK_REPLACE 0x08000000 // planning mode RSoP assumes replace loop back
  1003. #define FLAG_ASSUME_USER_WQLFILTER_TRUE 0x04000000 // planning mode RSoP assumes all comp filters to be true
  1004. #define FLAG_ASSUME_COMP_WQLFILTER_TRUE 0x02000000 // planning mode RSoP assumes all user filters to be true
  1005. #define FLAG_INTERNAL_MASK 0x01FFFFFF
  1006. // diagnostic mode provider flags
  1007. #define FLAG_NO_USER 0x00000001 // Don't get any user data
  1008. #define FLAG_NO_COMPUTER 0x00000002 // Don't get any machine data
  1009. #define FLAG_FORCE_CREATENAMESPACE 0x00000004
  1010. // Delete and recreate the namespace for this snapshot.
  1011. //=============================================================================
  1012. //
  1013. // Extended Errors returned by RSoP WMI Providers
  1014. //
  1015. //=============================================================================
  1016. // User accessing the rsop provider doesn't have access to user data.
  1017. #define RSOP_USER_ACCESS_DENIED 0x00000001
  1018. // User accessing the rsop provider doesn't have access to computer data.
  1019. #define RSOP_COMPUTER_ACCESS_DENIED 0x00000002
  1020. // This user is an interactive non admin user, the temp snapshot namespace already exists
  1021. // and the FLAG_FORCE_CREATENAMESPACE was not passed in
  1022. #define RSOP_TEMPNAMESPACE_EXISTS 0x00000004
  1023. ;begin_internal
  1024. #ifndef _USERENV_NO_LINK_APIS_
  1025. //=============================================================================
  1026. //
  1027. // CreateGroup
  1028. //
  1029. // Creates a program group on the start menu
  1030. //
  1031. // lpGroupName - Name of group
  1032. // bCommonGroup - Common or personal group
  1033. //
  1034. // Returns: TRUE if successful
  1035. // FALSE if not. Call GetLastError() for more details
  1036. //
  1037. //=============================================================================
  1038. USERENVAPI
  1039. BOOL
  1040. WINAPI
  1041. CreateGroup%(
  1042. IN LPCTSTR% lpGroupName,
  1043. IN BOOL bCommonGroup);
  1044. //=============================================================================
  1045. //
  1046. // CreateGroupEx
  1047. //
  1048. // Creates a program group on the start menu
  1049. //
  1050. // lpGroupName - Name of group
  1051. // bCommonGroup - Common or personal group
  1052. // lpResourceModuleName - Name of the resource module.
  1053. // uResourceID - Resource ID for the MUI display name.
  1054. //
  1055. // Returns: TRUE if successful
  1056. // FALSE if not. Call GetLastError() for more details
  1057. //
  1058. //=============================================================================
  1059. USERENVAPI
  1060. BOOL
  1061. WINAPI
  1062. CreateGroupEx%(
  1063. IN LPCTSTR% lpGroupName,
  1064. IN BOOL bCommonGroup,
  1065. IN LPCTSTR% lpResourceModuleName,
  1066. IN UINT uResourceID);
  1067. //=============================================================================
  1068. //
  1069. // DeleteGroup
  1070. //
  1071. // Deletes a program group on the start menu and all of its contents
  1072. //
  1073. // lpGroupName - Name of group
  1074. // bCommonGroup - Common or personal group
  1075. //
  1076. // Returns: TRUE if successful
  1077. // FALSE if not. Call GetLastError() for more details
  1078. //
  1079. // Note: This function uses a delnode routine. Make sure you really want
  1080. // to delete the group before you call this function.
  1081. //
  1082. //=============================================================================
  1083. USERENVAPI
  1084. BOOL
  1085. WINAPI
  1086. DeleteGroup%(
  1087. IN LPCTSTR% lpGroupName,
  1088. IN BOOL bCommonGroup);
  1089. //=============================================================================
  1090. //
  1091. // AddItem
  1092. //
  1093. // Creates an item on the Programs portion of the Start Menu in the
  1094. // requested group.
  1095. //
  1096. // lpGroupName - Name of group
  1097. // bCommonGroup - Common or personal group
  1098. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1099. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1100. // lpIconPath - Optional icon path, can be NULL.
  1101. // iIconIndex - Optional icon index, default to 0.
  1102. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1103. // wHotKey - Hot key for the link file, default to 0
  1104. // iShowCmd - Specifies how the application should be launched.
  1105. // Use a default of SW_SHOWNORMAL
  1106. //
  1107. // Returns: TRUE if successful
  1108. // FALSE if not. Call GetLastError() for more details
  1109. //
  1110. // Notes: New applications should use the CreateLinkFile() function instead
  1111. // of AddItem. This allows for friendly tooltip descriptions.
  1112. //
  1113. // The lpFileName argument should not include the .lnk extension.
  1114. // This function will add the extension.
  1115. //
  1116. // If the lpWorkingDirectory parameter is NULL, this function will
  1117. // insert the home directory environment variables
  1118. //
  1119. // If the requested group doesn't exist, it will be created.
  1120. //
  1121. // If the lpCommandLine target is located below the system root,
  1122. // the SystemRoot environment variable will be inserted into the path
  1123. //
  1124. // Here's a sample of how this function is typically called:
  1125. //
  1126. // AddItem (TEXT("Accessories"), FALSE, TEXT("Notepad"),
  1127. // TEXT("notepad.exe"), NULL, 0, NULL, 0, SW_SHOWNORMAL);
  1128. //
  1129. // This function should only be used the Windows NT team. Developers
  1130. // outside of the Windows NT team can use the IShellLink interface
  1131. // to create link files.
  1132. //
  1133. //=============================================================================
  1134. USERENVAPI
  1135. BOOL
  1136. WINAPI
  1137. AddItem%(
  1138. IN LPCTSTR% lpGroupName,
  1139. IN BOOL bCommonGroup,
  1140. IN LPCTSTR% lpFileName,
  1141. IN LPCTSTR% lpCommandLine,
  1142. IN LPCTSTR% lpIconPath,
  1143. IN INT iIconIndex,
  1144. IN LPCTSTR% lpWorkingDirectory,
  1145. IN WORD wHotKey,
  1146. IN INT iShowCmd);
  1147. //=============================================================================
  1148. //
  1149. // DeleteItem
  1150. //
  1151. // Deletes an item on the Programs portion of the Start Menu in the
  1152. // requested group.
  1153. //
  1154. // lpGroupName - Name of group
  1155. // bCommonGroup - Common or personal group
  1156. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1157. // bDeleteGroup - After deleting the link, delete the group if its empty.
  1158. //
  1159. // Returns: TRUE if successful
  1160. // FALSE if not. Call GetLastError() for more details
  1161. //
  1162. // Notes: New applications should use the DeleteLinkFile() function instead
  1163. // of DeleteItem.
  1164. //
  1165. // The lpFileName argument should not include the .lnk extension.
  1166. // This function will add the extension.
  1167. //
  1168. // Here's a sample of how this function is typically called:
  1169. //
  1170. // DeleteItem (TEXT("Accessories"), FALSE, TEXT("Notepad"), TRUE);
  1171. //
  1172. // This function should only be used the Windows NT team. Developers
  1173. // outside of the Windows NT team can use the IShellLink interface
  1174. // to create link files and DeleteFile to delete them.
  1175. //
  1176. //=============================================================================
  1177. USERENVAPI
  1178. BOOL
  1179. WINAPI
  1180. DeleteItem%(
  1181. IN LPCTSTR% lpGroupName,
  1182. IN BOOL bCommonGroup,
  1183. IN LPCTSTR% lpFileName,
  1184. IN BOOL bDeleteGroup);
  1185. //=============================================================================
  1186. //
  1187. // AddDesktopItem
  1188. //
  1189. // Creates an item on desktop. This function is very similar to AddItem()
  1190. // documented above. See that function for more information.
  1191. //
  1192. // Notes: New applications should use the CreateLinkFile() function instead
  1193. // of AddItem. This allows for friendly tooltip descriptions.
  1194. //
  1195. // This function should only be used the Windows NT team. Developers
  1196. // outside of the Windows NT team can use the IShellLink interface
  1197. // to create link files.
  1198. //
  1199. //=============================================================================
  1200. USERENVAPI
  1201. BOOL
  1202. WINAPI
  1203. AddDesktopItem%(
  1204. IN BOOL bCommonItem,
  1205. IN LPCTSTR% lpFileName,
  1206. IN LPCTSTR% lpCommandLine,
  1207. IN LPCTSTR% lpIconPath,
  1208. IN INT iIconIndex,
  1209. IN LPCTSTR% lpWorkingDirectory,
  1210. IN WORD wHotKey,
  1211. IN INT iShowCmd);
  1212. //=============================================================================
  1213. //
  1214. // DeleteDesktopItem
  1215. //
  1216. // Deletes an item from the desktop. This function is very similar to DeleteItem()
  1217. // documented above. See that function for more information.
  1218. //
  1219. // Notes: New applications should use the DeleteLinkFile() function instead
  1220. // of DeleteDesktopItem.
  1221. //
  1222. // This function should only be used the Windows NT team. Developers
  1223. // outside of the Windows NT team can use the IShellLink interface
  1224. // to create link files and DeleteFile to delete them.
  1225. //
  1226. //=============================================================================
  1227. USERENVAPI
  1228. BOOL
  1229. WINAPI
  1230. DeleteDesktopItem%(
  1231. IN BOOL bCommonItem,
  1232. IN LPCTSTR% lpFileName);
  1233. //=============================================================================
  1234. //
  1235. // CreateLinkFile
  1236. //
  1237. // Creates a link file (aka shortcut) in the requested special folder or
  1238. // subdirectory of a special folder.
  1239. //
  1240. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1241. // lpSubDirectory - Subdirectory name. See note below
  1242. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1243. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1244. // lpIconPath - Optional icon path, can be NULL.
  1245. // iIconIndex - Optional icon index, default to 0.
  1246. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1247. // wHotKey - Hot key for the link file, default to 0
  1248. // iShowCmd - Specifies how the application should be launched.
  1249. // Use a default of SW_SHOWNORMAL
  1250. // lpDescription - Friendly description of shortcut, can be NULL.
  1251. //
  1252. // Returns: TRUE if successful
  1253. // FALSE if not. Call GetLastError() for more details
  1254. //
  1255. // Notes: New applications should use this function instead of AddItem or
  1256. // AddDesktopItem. This allows for friendly tooltip descriptions.
  1257. //
  1258. // The link file name is a combination of the first three
  1259. // parameters. If a csidl is given, that special folder is
  1260. // looked up first, and then the lpSubDirectory is appended to
  1261. // it followed by the lpFileName. If csidl is equal to 0, then
  1262. // lpSubDirectory should contain the fully qualified path to the
  1263. // directory the link file is to be placed in. This allows
  1264. // for link files to be be created outside of the scope of a
  1265. // shell special folder. The csidl constants are listed in
  1266. // shlobj.h or in the Win32 documentation for SHGetSpecialFolderPath.
  1267. // Commonly used csidl's will be:
  1268. //
  1269. // CSIDL_PROGRAMS - Personal Program folder on Start Menu
  1270. // CSIDL_COMMON_PROGRAMS - Common Program folder on Start Menu
  1271. // CSIDL_DESKTOPDIRECTORY - Personal desktop folder
  1272. // CSIDL_COMMON_DESKTOPDIRECTORY - Common desktop folder
  1273. //
  1274. // The lpFileName argument should not include the .lnk extension.
  1275. // This function will add the extension.
  1276. //
  1277. // If the lpWorkingDirectory parameter is NULL, this function will
  1278. // insert home directory environment variables.
  1279. //
  1280. // If the requested subdirectory doesn't exist, it will be created.
  1281. //
  1282. // If the lpCommandLine target is located below the system root,
  1283. // the SystemRoot environment variable will be inserted into the path
  1284. //
  1285. // Here's a sample of how this function is typically called:
  1286. //
  1287. // CreateLinkFile (CSIDL_PROGRAMS, TEXT("Accessories"), TEXT("Notepad"),
  1288. // TEXT("notepad.exe"), NULL, 0, NULL, 0, SW_SHOWNORMAL,
  1289. // TEXT("A simple word processor."));
  1290. //
  1291. // This function should only be used the Windows NT team. Developers
  1292. // outside of the Windows NT team can use the IShellLink interface
  1293. // to create link files.
  1294. //
  1295. //=============================================================================
  1296. ;begin_winver_500
  1297. USERENVAPI
  1298. BOOL
  1299. WINAPI
  1300. CreateLinkFile%(
  1301. IN INT csidl,
  1302. IN LPCTSTR% lpSubDirectory,
  1303. IN LPCTSTR% lpFileName,
  1304. IN LPCTSTR% lpCommandLine,
  1305. IN LPCTSTR% lpIconPath,
  1306. IN INT iIconIndex,
  1307. IN LPCTSTR% lpWorkingDirectory,
  1308. IN WORD wHotKey,
  1309. IN INT iShowCmd,
  1310. IN LPCTSTR% lpDescription);
  1311. ;end_winver_500
  1312. //=============================================================================
  1313. //
  1314. // CreateLinkFileEx
  1315. //
  1316. // Creates a link file (aka shortcut) in the requested special folder or
  1317. // subdirectory of a special folder.
  1318. //
  1319. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1320. // lpSubDirectory - Subdirectory name. See note below
  1321. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1322. // lpCommandLine - Command line of target path (eg: notepad.exe)
  1323. // lpIconPath - Optional icon path, can be NULL.
  1324. // iIconIndex - Optional icon index, default to 0.
  1325. // lpWorkingDirectory - Working directory when target is invoked, can be NULL
  1326. // wHotKey - Hot key for the link file, default to 0
  1327. // iShowCmd - Specifies how the application should be launched.
  1328. // Use a default of SW_SHOWNORMAL
  1329. // lpDescription - Friendly description of shortcut, can be NULL.
  1330. // lpResourceModuleName - Name of the resource module. Can be NULL
  1331. // uResourceID - Resource ID for the MUI display name.
  1332. //
  1333. // Returns: TRUE if successful
  1334. // FALSE if not. Call GetLastError() for more details
  1335. //
  1336. // for additional descriptions look in the description of Createlinkfile above.
  1337. //=============================================================================
  1338. ;begin_winver_500
  1339. USERENVAPI
  1340. BOOL
  1341. WINAPI
  1342. CreateLinkFileEx%(
  1343. IN INT csidl,
  1344. IN LPCTSTR% lpSubDirectory,
  1345. IN LPCTSTR% lpFileName,
  1346. IN LPCTSTR% lpCommandLine,
  1347. IN LPCTSTR% lpIconPath,
  1348. IN INT iIconIndex,
  1349. IN LPCTSTR% lpWorkingDirectory,
  1350. IN WORD wHotKey,
  1351. IN INT iShowCmd,
  1352. IN LPCTSTR% lpDescription,
  1353. IN LPCTSTR% lpResourceModuleName,
  1354. IN UINT uResourceID);
  1355. ;end_winver_500
  1356. //=============================================================================
  1357. //
  1358. // DeleteLinkFile
  1359. //
  1360. // Deletes a link file (aka shortcut) in the requested special folder or
  1361. // subdirectory of a special folder.
  1362. //
  1363. // csidl - CSIDL_* constant of special folder. See shlobj.h
  1364. // lpSubDirectory - Subdirectory name. See note below
  1365. // lpFileName - Name of link without the .lnk extension (eg: Notepad)
  1366. // bDeleteSubDirectory - After deleting the link, delete the subdirectory if its empty.
  1367. //
  1368. // Returns: TRUE if successful
  1369. // FALSE if not. Call GetLastError() for more details
  1370. //
  1371. // Notes: New applications should use this function instead DeleteItem or
  1372. // DeleteDesktopItem.
  1373. //
  1374. // The link file name is a combination of the first three
  1375. // parameters. If a csidl is given, that special folder is
  1376. // looked up first, and then the lpSubDirectory is appended to
  1377. // it followed by the lpFileName. If csidl is equal to 0, then
  1378. // lpSubDirectory should contain the fully qualified path to the
  1379. // directory the link file is to be placed in. This allows
  1380. // for link files to be be deleted outside of the scope of a
  1381. // shell special folder. The csidl constants are listed in
  1382. // shlobj.h or in the Win32 documentation for SHGetSpecialFolderPath.
  1383. // Commonly used csidl's will be:
  1384. //
  1385. // CSIDL_PROGRAMS - Personal Program folder on Start Menu
  1386. // CSIDL_COMMON_PROGRAMS - Common Program folder on Start Menu
  1387. // CSIDL_DESKTOPDIRECTORY - Personal desktop folder
  1388. // CSIDL_COMMON_DESKTOPDIRECTORY - Common desktop folder
  1389. //
  1390. // The lpFileName argument should not include the .lnk extension.
  1391. // This function will add the extension.
  1392. //
  1393. // This function should only be used the Windows NT team. Developers
  1394. // outside of the Windows NT team can use the IShellLink interface
  1395. // to create link files and DeleteFile to delete them.
  1396. //
  1397. //=============================================================================
  1398. ;begin_winver_500
  1399. USERENVAPI
  1400. BOOL
  1401. WINAPI
  1402. DeleteLinkFile%(
  1403. IN INT csidl,
  1404. IN LPCTSTR% lpSubDirectory,
  1405. IN LPCTSTR% lpFileName,
  1406. IN BOOL bDeleteSubDirectory);
  1407. ;end_winver_500
  1408. #endif // _USERENV_NO_LINK_APIS_
  1409. //=============================================================================
  1410. //
  1411. // InitializeProfiles
  1412. //
  1413. // This function is used by GUI mode setup only and setup repair. It initializes
  1414. // the Default User and All User profiles and converts any common groups from
  1415. // Program Manager.
  1416. //
  1417. // bGuiModeSetup - Gui Mode setup or not.
  1418. //
  1419. //
  1420. // Returns: TRUE if successful
  1421. // FALSE if not. Call GetLastError() for more details
  1422. //
  1423. //=============================================================================
  1424. USERENVAPI
  1425. BOOL
  1426. WINAPI
  1427. InitializeProfiles(
  1428. IN BOOL bGuiModeSetup);
  1429. //*************************************************************
  1430. //
  1431. // CopySystemProfile()
  1432. //
  1433. // Purpose: Create the system profile information under
  1434. // ProfileList entry.
  1435. // In case of upgrade copy system profile from older
  1436. // location to new location and delete the old system
  1437. // profile
  1438. //
  1439. // Parameters:
  1440. //
  1441. // Return: TRUE if successful
  1442. // FALSE if an error occurs. Call GetLastError()
  1443. //
  1444. // Comments: This should only be called by GUI mode setup!
  1445. //
  1446. //*************************************************************
  1447. USERENVAPI
  1448. BOOL
  1449. WINAPI
  1450. CopySystemProfile(
  1451. IN BOOL bCleanInstall);
  1452. //=============================================================================
  1453. //
  1454. // DetermineProfilesLocation
  1455. //
  1456. // This function is used by winlogon when GUI mode setup is about to start.
  1457. // It sets the correct user profile location in the registry.
  1458. //
  1459. // bCleanInstall - True if setup is performing a clean install
  1460. //
  1461. // Returns: TRUE if successful
  1462. // FALSE if not. Call GetLastError() for more details
  1463. //
  1464. //=============================================================================
  1465. ;begin_winver_500
  1466. USERENVAPI
  1467. BOOL
  1468. WINAPI
  1469. DetermineProfilesLocation(
  1470. BOOL bCleanInstall);
  1471. ;end_winver_500
  1472. //=============================================================================
  1473. //
  1474. // CreateUserProfile(Ex)
  1475. //
  1476. // Creates a user profile for the given user. Used by the Win95 -> NT5
  1477. // migration code.
  1478. //
  1479. // pSid - SID of new user
  1480. // lpUserName - User name of new user
  1481. // lpUserHive - Registry hive to use (optional, can be NULL)
  1482. // lpProfileDir - Receives the user's profile directory (can be NULL)
  1483. // dwDirSize - Size of lpProfileDir
  1484. // bWin9xUpg - Flag to say whether it is win9x upgrade
  1485. //
  1486. // Returns: TRUE if successful
  1487. // FALSE if not.
  1488. //
  1489. //=============================================================================
  1490. ;begin_winver_500
  1491. USERENVAPI
  1492. BOOL
  1493. WINAPI
  1494. CreateUserProfile%(
  1495. IN PSID pSid,
  1496. IN LPCTSTR% lpUserName,
  1497. IN LPCTSTR% lpUserHive,
  1498. OUT LPTSTR% lpProfileDir,
  1499. IN DWORD dwDirSize);
  1500. USERENVAPI
  1501. BOOL
  1502. WINAPI
  1503. CreateUserProfileEx%(
  1504. IN PSID pSid,
  1505. IN LPCTSTR% lpUserName,
  1506. IN LPCTSTR% lpUserHive,
  1507. OUT LPTSTR% lpProfileDir,
  1508. IN DWORD dwDirSize,
  1509. IN BOOL bWin9xUpg);
  1510. ;end_winver_500
  1511. //=============================================================================
  1512. //
  1513. // CopyProfileDirectory(Ex)
  1514. //
  1515. // Multi-threaded user profile coping algorithm.
  1516. //
  1517. // lpSourceDir - Source directory
  1518. // lpDestinationDir - Destination directory
  1519. // dwFlags - Flags (defined below)
  1520. // ftDelRefTime - Reference time used when deleted extra files
  1521. // in a CPD_SYNCHRONIZE operation
  1522. // lpExclusionList - List of directories to exclude when copying the
  1523. // profile
  1524. //
  1525. // Returns: TRUE if successful
  1526. // FALSE if not.
  1527. //
  1528. // Notes: When CPD_SYNCHRONIZE is used to copy a profile from one
  1529. // location to another, all the files / directories are copied first
  1530. // and then extra files in the target directory are deleted. In the
  1531. // case of 2 machines using the same roaming profile, it doesn't make
  1532. // sense to delete the extra files everytime. If the CPD_USEDELREFTIME
  1533. // flag is set, then before deleting a file or directory, the
  1534. // time on that file or directory is compared with ftDelRefTime.
  1535. // If the time is newer, the file / directory is not deleted because
  1536. // it is probably a new file from a different machine. If the
  1537. // time is older, the file / directory is deleted.
  1538. //
  1539. // CopyProfileDirectoryEx can also exclude certain directories
  1540. // from the copy. If the CPD_USEEXCLUSIONLIST flag is set and
  1541. // lpExclusionList is non-null, the specified directories (and
  1542. // their children) will be excuded from the copy. The format
  1543. // of this parameter is a semi-colon separated list of directories
  1544. // relative to the root of the source profile. For example:
  1545. //
  1546. // Temporary Internet Files;Temp;Foo\Bar
  1547. //
  1548. //=============================================================================
  1549. //
  1550. // Flags for CopyProfileDirectory(Ex)
  1551. //
  1552. #define CPD_FORCECOPY 0x00000001 // Ignore time stamps and always copy the file
  1553. #define CPD_IGNORECOPYERRORS 0x00000002 // Ignore errors and keep going
  1554. #define CPD_IGNOREHIVE 0x00000004 // Don't copy registry hive
  1555. #define CPD_WIN95HIVE 0x00000008 // Looking for Win 9x registry hive instead of NT registry hive
  1556. #define CPD_COPYIFDIFFERENT 0x00000010 // If a file exists in both src and dest with different time stamps, always copy it.
  1557. #define CPD_SYNCHRONIZE 0x00000020 // Make dest directory structure indentical to src directory structure (delete extra files and directories)
  1558. #define CPD_SLOWCOPY 0x00000040 // Don't use multiple thread. Copy one file at a time.
  1559. #define CPD_SHOWSTATUS 0x00000080 // Show progress dialog
  1560. #define CPD_CREATETITLE 0x00000100 // Change progress dialog title to Creating... rather than Copying...
  1561. #define CPD_COPYHIVEONLY 0x00000200 // Only copy the hive, no other files
  1562. #define CPD_USEDELREFTIME 0x00000400 // Use ftDelRefTime parameter in CopyProfileDirectoryEx
  1563. #define CPD_USEEXCLUSIONLIST 0x00000800 // Use lpExclusionList parameter in CopyProfileDirectoryEx
  1564. #define CPD_SYSTEMFILES 0x00001000 // Only copy files and directories with the system file attribute set
  1565. #define CPD_DELDESTEXCLUSIONS 0x00002000 // If a directory that is excluded in the source already exists in the destination, delete it
  1566. #define CPD_NONENCRYPTEDONLY 0x00004000 // Copy only non encrypted files
  1567. #define CPD_IGNORESECURITY 0x00008000 // Ignore the ACLs etc. on the source files
  1568. #define CPD_NOERRORUI 0x00010000 // Do not show the UI if error occurs
  1569. #define CPD_SYSTEMDIRSONLY 0x00020000 // Only copy directories with the system file attribute set
  1570. #define CPD_IGNOREENCRYPTEDFILES 0x00040000 // Ignore Encrypted files
  1571. #define CPD_IGNORELONGFILENAMES 0x00080000 // Ignore files with long file names
  1572. #define CPD_USETMPHIVEFILE 0x00100000 // user hive is still loaded
  1573. USERENVAPI
  1574. BOOL
  1575. WINAPI
  1576. CopyProfileDirectory%(
  1577. IN LPCTSTR% lpSourceDir,
  1578. IN LPCTSTR% lpDestinationDir,
  1579. IN DWORD dwFlags);
  1580. USERENVAPI
  1581. BOOL
  1582. WINAPI
  1583. CopyProfileDirectoryEx%(
  1584. IN LPCTSTR% lpSourceDir,
  1585. IN LPCTSTR% lpDestinationDir,
  1586. IN DWORD dwFlags,
  1587. IN LPFILETIME ftDelRefTime,
  1588. IN LPCTSTR% lpExclusionList);
  1589. //=============================================================================
  1590. //
  1591. // MigrateNT4ToNT5
  1592. //
  1593. // Migrates a user's profile from NT4 to NT5. This function should
  1594. // only be called by shmgrate.exe
  1595. //
  1596. // Returns: TRUE if successful
  1597. // FALSE if not.
  1598. //
  1599. //=============================================================================
  1600. ;begin_winver_500
  1601. USERENVAPI
  1602. BOOL
  1603. WINAPI
  1604. MigrateNT4ToNT5();
  1605. ;end_winver_500
  1606. //=============================================================================
  1607. //
  1608. // ResetUserSpecialFolderPaths
  1609. //
  1610. // Sets all of the user special folder paths back to their defaults
  1611. //
  1612. // Returns: TRUE if successful
  1613. // FALSE if not.
  1614. //
  1615. //=============================================================================
  1616. ;begin_winver_500
  1617. USERENVAPI
  1618. BOOL
  1619. WINAPI
  1620. ResetUserSpecialFolderPaths();
  1621. ;end_winver_500
  1622. //=============================================================================
  1623. //
  1624. // GetSystemTempDirectory
  1625. //
  1626. // Gets the system wide temp directory in short form
  1627. //
  1628. // Returns: TRUE if successful
  1629. // FALSE if not.
  1630. //
  1631. //=============================================================================
  1632. USERENVAPI
  1633. BOOL
  1634. WINAPI
  1635. GetSystemTempDirectory%(
  1636. OUT LPTSTR% lpDir,
  1637. IN OUT LPDWORD lpcchSize);
  1638. //=============================================================================
  1639. //
  1640. // ApplySystemPolicy
  1641. //
  1642. //
  1643. // Entry point for Windows NT4 System Policy.
  1644. //
  1645. // dwFlags - Flags
  1646. // hToken - User's token
  1647. // hKeyCurrentUser - Registry to the root of the user's hive
  1648. // lpUserName - User's name
  1649. // lpPolicyPath - Path to the policy file (ntconfig.pol). Can be NULL.
  1650. // lpServerName - Domain controller name used for group
  1651. // membership look up. Can be NULL.
  1652. //
  1653. //
  1654. // Returns: TRUE if successful
  1655. // FALSE if not
  1656. //
  1657. //=============================================================================
  1658. ;begin_winver_500
  1659. #define SP_FLAG_APPLY_MACHINE_POLICY 0x00000001
  1660. #define SP_FLAG_APPLY_USER_POLICY 0x00000002
  1661. USERENVAPI
  1662. BOOL
  1663. WINAPI
  1664. ApplySystemPolicy%(
  1665. IN DWORD dwFlags,
  1666. IN HANDLE hToken,
  1667. IN HKEY hKeyCurrentUser,
  1668. IN LPCTSTR% lpUserName,
  1669. IN LPCTSTR% lpPolicyPath,
  1670. IN LPCTSTR% lpServerName);
  1671. ;end_winver_500
  1672. ;begin_winver_500
  1673. //=============================================================================
  1674. //
  1675. // Data types and data structures for foreground policy refresh info.
  1676. //
  1677. //=============================================================================
  1678. typedef enum _tagFgPolicyRefreshReason
  1679. {
  1680. GP_ReasonUnknown = 0,
  1681. GP_ReasonFirstPolicy,
  1682. GP_ReasonCSERequiresSync,
  1683. GP_ReasonCSESyncError,
  1684. GP_ReasonSyncForced,
  1685. GP_ReasonSyncPolicy,
  1686. GP_ReasonNonCachedCredentials,
  1687. GP_ReasonSKU
  1688. } FgPolicyRefreshReason;
  1689. typedef enum _tagFgPolicyRefreshMode
  1690. {
  1691. GP_ModeUnknown = 0,
  1692. GP_ModeSyncForeground,
  1693. GP_ModeAsyncForeground,
  1694. } FgPolicyRefreshMode;
  1695. typedef struct _tagFgPolicyRefreshInfo
  1696. {
  1697. FgPolicyRefreshReason reason;
  1698. FgPolicyRefreshMode mode;
  1699. } FgPolicyRefreshInfo, *LPFgPolicyRefreshInfo;
  1700. //=============================================================================
  1701. //
  1702. // SetNextFgPolicyRefreshInfo
  1703. //
  1704. // Sets information about the next foreground policy
  1705. //
  1706. // szUserSid - user's SID for user's info, 0 for machine info
  1707. // info - FgPolicyRefreshInfo structure with the reason and mode info
  1708. //
  1709. // Returns: WIN32 error code
  1710. //
  1711. //=============================================================================
  1712. USERENVAPI
  1713. DWORD
  1714. WINAPI
  1715. SetNextFgPolicyRefreshInfo( LPWSTR szUserSid,
  1716. FgPolicyRefreshInfo info );
  1717. //=============================================================================
  1718. //
  1719. // GetPreviousFgPolicyRefreshInfo
  1720. //
  1721. // Gets information about the previous foreground policy
  1722. //
  1723. // szUserSid - user's SID for user's info, 0 for machine info
  1724. // pInfo - pointer to the FgPolicyRefreshInfo structure; returns the info
  1725. //
  1726. // Returns: WIN32 error code
  1727. //
  1728. //=============================================================================
  1729. USERENVAPI
  1730. DWORD
  1731. WINAPI
  1732. GetPreviousFgPolicyRefreshInfo( LPWSTR szUserSid,
  1733. FgPolicyRefreshInfo* pInfo );
  1734. //=============================================================================
  1735. //
  1736. // GetNextFgPolicyRefreshInfo
  1737. //
  1738. // Gets information about the previous foreground policy
  1739. //
  1740. // szUserSid - user's SID for user's info, 0 for machine info
  1741. // pInfo - pointer to the FgPolicyRefreshInfo structure; returns info
  1742. //
  1743. // Returns: WIN32 error code
  1744. //
  1745. //=============================================================================
  1746. USERENVAPI
  1747. DWORD
  1748. WINAPI
  1749. GetNextFgPolicyRefreshInfo( LPWSTR szUserSid,
  1750. FgPolicyRefreshInfo* pInfo );
  1751. //=============================================================================
  1752. //
  1753. // ForceSyncFgPolicy
  1754. //
  1755. // Forces the next foreground policy to be Synchronous
  1756. //
  1757. // szUserSid - user's SID for user's info, 0 for machine info
  1758. //
  1759. // Returns: WIN32 error code
  1760. //
  1761. //=============================================================================
  1762. USERENVAPI
  1763. DWORD
  1764. WINAPI
  1765. ForceSyncFgPolicy( LPWSTR szUserSid );
  1766. //=============================================================================
  1767. //
  1768. // WaitForUserPolicyForegroundProcessing
  1769. //
  1770. // Blocks the caller until the user foreground policy is finished
  1771. //
  1772. // Returns: WIN32 error code
  1773. //
  1774. //=============================================================================
  1775. USERENVAPI
  1776. DWORD
  1777. WINAPI
  1778. WaitForUserPolicyForegroundProcessing();
  1779. //=============================================================================
  1780. //
  1781. // WaitForMachinePolicyForegroundProcessing
  1782. //
  1783. // Blocks the caller until the machine foreground policy is finished
  1784. //
  1785. // Returns: WIN32 error code
  1786. //
  1787. //=============================================================================
  1788. USERENVAPI
  1789. DWORD
  1790. WINAPI
  1791. WaitForMachinePolicyForegroundProcessing();
  1792. //=============================================================================
  1793. //
  1794. // IsSyncForegroundPolicyRefresh
  1795. //
  1796. // Called during foreground refresh to determine whether the refresh is sync or
  1797. // async
  1798. //
  1799. // bMachine - user or machine
  1800. // hToken - User or machine token
  1801. //
  1802. // Returns: TRUE if foreground policy should be applied synchronously,
  1803. // FALSE otherwise
  1804. //
  1805. //=============================================================================
  1806. USERENVAPI
  1807. BOOL
  1808. WINAPI
  1809. IsSyncForegroundPolicyRefresh( BOOL bMachine,
  1810. HANDLE hToken );
  1811. ;end_winver_500
  1812. //=============================================================================
  1813. //
  1814. // ApplyGroupPolicy
  1815. //
  1816. //
  1817. // Entry point for Group Policy. Causes either machine or user
  1818. // policy to be applied.
  1819. //
  1820. // dwFlags - Flags defined below
  1821. // hToken - User or machine token
  1822. // hEvent - Handle to an event which causes the policy thread to
  1823. // terminate when signaled.
  1824. // hKeyRoot - Registry to the root of the correspond hive
  1825. // eg: HKLM or HKCU for the user that matches hToken
  1826. // pStatusCallback - Callback function for displaying status messages
  1827. //
  1828. //
  1829. // Returns: If GP_BACKGROUND_REFRESH is set, a thread handle
  1830. // the process can wait until after signaling for policy
  1831. // to stop. If GPT_BACKGROUND_REFRESH is not set, the
  1832. // return value is 1.
  1833. //
  1834. // In the case of failure, NULL will be returned.
  1835. //
  1836. //=============================================================================
  1837. ;begin_winver_500
  1838. //
  1839. // Flags to the ApplyGroupPolicy() function
  1840. //
  1841. #define GP_MACHINE 0x00000001 // Process for machine (vs user)
  1842. #define GP_BACKGROUND_REFRESH 0x00000002 // Use background thread
  1843. #define GP_APPLY_DS_POLICY 0x00000004 // Apply policy from the DS also
  1844. #define GP_ASYNC_FOREGROUND 0x00000008 // don't wait on network services
  1845. //
  1846. // Flags set by ApplyGroupPolicy() function (do not pass these in)
  1847. //
  1848. #define GP_BACKGROUND_THREAD 0x00010000 // Background thread processing
  1849. #define GP_REGPOLICY_CPANEL 0x00020000 // Something changed in the CP settings
  1850. #define GP_SLOW_LINK 0x00040000 // Slow network connection
  1851. #define GP_VERBOSE 0x00080000 // Verbose output to eventlog
  1852. #define GP_FORCED_REFRESH 0x00100000 // Forced Refresh
  1853. // The 2 bit values were briefly used.
  1854. #define GP_PLANMODE 0x00800000 // Planning mode flag
  1855. USERENVAPI
  1856. HANDLE
  1857. WINAPI
  1858. ApplyGroupPolicy(
  1859. IN DWORD dwFlags,
  1860. IN HANDLE hToken,
  1861. IN HANDLE hEvent,
  1862. IN HKEY hKeyRoot,
  1863. IN PFNSTATUSMESSAGECALLBACK pStatusCallback);
  1864. //=============================================================================
  1865. //
  1866. // GenerateRsopPolicy
  1867. //
  1868. // Generates planning mode Rsop policy for specified target
  1869. //
  1870. // dwFlags - Processing flags
  1871. // bstrMachName - Target computer name
  1872. // bstrNewMachSOM - New machine domain or OU
  1873. // psaMachSecGroups - New machine security groups
  1874. // bstrUserName - Target user name
  1875. // psaUserSecGroups - New user security groups
  1876. // bstrSite - Site of target computer
  1877. // pwszNameSpace - Namespace to write Rsop data
  1878. // pProgress - Progress indicator info
  1879. // pMachGpoFilter - GPO Filters that pass in machine processing
  1880. // pUserGpoFilter - GPO Filters that pass in user processing
  1881. //
  1882. // Return: True if successful, False otherwise
  1883. //
  1884. //=============================================================================
  1885. USERENVAPI
  1886. BOOL
  1887. WINAPI
  1888. GenerateRsopPolicy(
  1889. IN DWORD dwFlags,
  1890. IN BSTR bstrMachName,
  1891. IN BSTR bstrNewMachSOM,
  1892. IN SAFEARRAY *psaMachSecGroups,
  1893. IN BSTR bstrUserName,
  1894. IN BSTR bstrNewUserSOM,
  1895. IN SAFEARRAY *psaUserSecGroups,
  1896. IN BSTR bstrSite,
  1897. IN WCHAR *pwszNameSpace,
  1898. IN LPVOID pProgress,
  1899. IN LPVOID pMachGpoFilter,
  1900. IN LPVOID pUserGpoFilter);
  1901. ;end_winver_500
  1902. //=============================================================================
  1903. //
  1904. // ShutdownGPOProcessing()
  1905. //
  1906. // Entry point for aborting GPO processing
  1907. //
  1908. // bMachine - Shutdown machine or user processing ?
  1909. //
  1910. // Returns: void
  1911. //
  1912. //=============================================================================
  1913. ;begin_winver_500
  1914. USERENVAPI
  1915. void
  1916. WINAPI
  1917. ShutdownGPOProcessing(
  1918. IN BOOL bMachine);
  1919. ;end_winver_500
  1920. //=============================================================================
  1921. //
  1922. // PingComputer()
  1923. //
  1924. // Pings the specified computer
  1925. //
  1926. // ipaddr - IP address of the computer in unsigned long form
  1927. // ulSpeed - Data transfer rate
  1928. //
  1929. // Notes: For fast connections (eg: LAN), it isn't possible
  1930. // to get accurate transfer rates since the response
  1931. // time from the computer is less than 10ms. In
  1932. // this case, the function returns ERROR_SUCCESS
  1933. // and ulSpeed is set to 0. If the function returns
  1934. // ERROR_SUCCESS and the ulSpeed argument is non-zero
  1935. // the connections is slower
  1936. //
  1937. // Returns: ERROR_SUCCESS if successful
  1938. // Win32 error code if not
  1939. //
  1940. //=============================================================================
  1941. ;begin_winver_500
  1942. USERENVAPI
  1943. DWORD
  1944. WINAPI
  1945. PingComputer(
  1946. IN ULONG ipaddr,
  1947. OUT ULONG *ulSpeed);
  1948. ;end_winver_500
  1949. //=============================================================================
  1950. //
  1951. // InitializeUserProfile()
  1952. //
  1953. // Called by winlogon to initialize userenv.dll for loading/unloading user
  1954. // profiles.
  1955. //
  1956. // Returns: fvoid
  1957. //
  1958. //=============================================================================
  1959. ;begin_winver_500
  1960. USERENVAPI
  1961. void
  1962. WINAPI
  1963. InitializeUserProfile();
  1964. ;end_winver_500
  1965. //=============================================================================
  1966. //
  1967. // EnterUserProfileLock()
  1968. //
  1969. // Get the user profile synchronization lock for a user
  1970. //
  1971. // Returns: HRESULT
  1972. //
  1973. //=============================================================================
  1974. ;begin_winver_500
  1975. USERENVAPI
  1976. DWORD
  1977. WINAPI
  1978. EnterUserProfileLock(LPTSTR pSid);
  1979. ;end_winver_500
  1980. //=============================================================================
  1981. //
  1982. // LeaveUserProfileLock()
  1983. //
  1984. // Release the user profile synchronization lock for a user
  1985. //
  1986. // Returns: HRESULT
  1987. //
  1988. //=============================================================================
  1989. ;begin_winver_500
  1990. USERENVAPI
  1991. DWORD
  1992. WINAPI
  1993. LeaveUserProfileLock(LPTSTR pSid);
  1994. ;end_winver_500
  1995. //*************************************************************************
  1996. //
  1997. // SecureUserProfiles()
  1998. //
  1999. // Routine Description :
  2000. // This function secures user profiles during FAT->NTFS conversion.
  2001. // The function loops through all profiles registered under current
  2002. // OS and sets the security for the corresponding profile directory
  2003. // and nested subdirs. Assumption is the function will be called
  2004. // only during FAT->NTFS conversion.
  2005. //
  2006. // Arguments :
  2007. // None.
  2008. //
  2009. // Return Value :
  2010. // None.
  2011. //
  2012. // History: Date Author Comment
  2013. // 8/8/00 santanuc Created
  2014. //
  2015. //*************************************************************************
  2016. ;begin_winver_500
  2017. USERENVAPI
  2018. void
  2019. WINAPI
  2020. SecureUserProfiles(void);
  2021. ;end_winver_500
  2022. //*************************************************************************
  2023. //
  2024. // CheckAccessForPolicyGeneration()
  2025. //
  2026. // Routine Description :
  2027. // This function checks whether the given user represented by the token
  2028. // has access to generate rsop data (planning or logging)
  2029. //
  2030. // Arguments :
  2031. // hToken - Token of the user
  2032. // szContainer - Container for which access needs to be checked.
  2033. // Should be OU or domain container
  2034. // szDomain - Domaindns where the container exists
  2035. // bLogging - True if the rsop data is to be genearated for
  2036. // logging mode
  2037. // pbAccessGranted - Access Granted or not
  2038. //
  2039. //
  2040. // Return Value :
  2041. // ERROR_SUCCESS on success. Appropriate error code otherwise
  2042. //
  2043. //*************************************************************************
  2044. ;begin_winver_500
  2045. USERENVAPI
  2046. DWORD
  2047. WINAPI
  2048. CheckAccessForPolicyGeneration( HANDLE hToken,
  2049. LPCWSTR szContainer,
  2050. LPWSTR szDomain,
  2051. BOOL bLogging,
  2052. BOOL* pbAccessGranted);
  2053. ;end_winver_500
  2054. //*************************************************************************
  2055. //
  2056. // GetGroupPolicyNetworkName()
  2057. //
  2058. // Routine Description :
  2059. // This function returns the name of the network from which policy
  2060. // was applied.
  2061. //
  2062. // Arguments :
  2063. // szNetworkName - unicode string buffer representing the network name
  2064. // pdwByteCount - size in bytes of the unicode string buffer
  2065. //
  2066. // Return Value :
  2067. // ERROR_SUCCESS if successful, error code otherwise.
  2068. //
  2069. //*************************************************************************
  2070. ;begin_winver_500
  2071. USERENVAPI
  2072. DWORD
  2073. WINAPI
  2074. GetGroupPolicyNetworkName( LPWSTR szNetworkName, LPDWORD pdwByteCount );
  2075. ;end_winver_500
  2076. //*************************************************************
  2077. //
  2078. // GetUserAppDataPath()
  2079. //
  2080. // Purpose: Returns the path for user's Appdata.
  2081. //
  2082. // Parameters: hToken - User's token
  2083. // lpFolderPath - Output buffer
  2084. //
  2085. // Return: ERROR_SUCCESS if successful
  2086. // otherwise the error code
  2087. //
  2088. // Comments: If error occurs then lpFolderPath set to empty.
  2089. // Used by Crypto guys to avoid calling SHGetFolderPath.
  2090. //
  2091. //*************************************************************
  2092. ;begin_winver_500
  2093. USERENVAPI
  2094. DWORD
  2095. WINAPI
  2096. GetUserAppDataPath%(
  2097. IN HANDLE hToken,
  2098. OUT LPTSTR% lpFolderPath);
  2099. ;end_winver_500
  2100. //=============================================================================
  2101. //
  2102. // GetUserProfileDirFromSid
  2103. //
  2104. // Returns the path to the root of the requested user's profile
  2105. //
  2106. // pSid - User's SID returned from LookupAccountName()
  2107. // lpProfileDir - Receives the path
  2108. // lpcchSize - Size of lpProfileDir
  2109. //
  2110. // Returns: TRUE if successful
  2111. // FALSE if not. Call GetLastError() for more details
  2112. //
  2113. // Note: If lpProfileDir is not large enough, the function will fail,
  2114. // and lpcchSize will contain the necessary buffer size.
  2115. //
  2116. // Example return value: C:\Documents and Settings\Joe
  2117. //
  2118. //=============================================================================
  2119. ;begin_winver_500
  2120. USERENVAPI
  2121. BOOL
  2122. WINAPI
  2123. GetUserProfileDirFromSid%(
  2124. IN PSID pSid,
  2125. OUT LPTSTR% lpProfileDir,
  2126. IN OUT LPDWORD lpcchSize);
  2127. ;end_winver_500
  2128. ;end_internal
  2129. ;begin_both
  2130. #ifdef __cplusplus
  2131. }
  2132. #endif
  2133. ;end_both
  2134. #endif // _INC_USERENV
  2135. #endif // _INC_USERENVP ;internal