Platform SDK: Group Policy |
The EnterCriticalPolicySection function pauses the background application of policy to allow safe reading of the registry. Applications should use this function if they read multiple policy entries and need to ensure that the values are not changed while they are being read.
HANDLE EnterCriticalPolicySection( BOOL bMachine );
If the function succeeds, the return value is a handle to a policy section.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
The maximum amount of time an application can hold a critical section is 10 minutes. After 10 minutes, the system releases the critical section and policy can be applied again.
If you need to acquire both the computer and user critical section objects, acquire the user critical section object before acquiring the computer critical section object. This will help prevent a deadlock situation.
To close the handle when you are finished, call the LeaveCriticalPolicySection function. The policy section handle cannot be used in any other Win32 functions.
Windows NT/2000: Requires Windows 2000.
Header: Declared in Userenv.h.
Library: Use Userenv.lib.
Group Policy Overview, Group Policy Functions, LeaveCriticalPolicySection