UserHandleGrantAccess function (winuser.h)

Grants or denies access to a handle to a User object to a job that has a user-interface restriction. When access is granted, all processes associated with the job can subsequently recognize and use the handle. When access is denied, the processes can no longer use the handle. For more information see User Objects.


BOOL UserHandleGrantAccess(
  [in] HANDLE hUserHandle,
  [in] HANDLE hJob,
  [in] BOOL   bGrant


[in] hUserHandle

A handle to the User object.

[in] hJob

A handle to the job to be granted access to the User handle. The CreateJobObject or OpenJobObject function returns this handle.

[in] bGrant

If this parameter is TRUE, all processes associated with the job can recognize and use the handle. If the parameter is FALSE, the processes cannot use the handle.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.


The UserHandleGrantAccess function can be called only from a process not associated with the job specified by the hJob parameter. The User handle must not be owned by a process or thread associated with the job.

To create user-interface restrictions, call the SetInformationJobObject function with the JobObjectBasicUIRestrictions job information class.


Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll

See also


Job Objects


Process and Thread Functions