Shell_NotifyIcon() fails with "invalid window handle" if job object has JOB_OBJECT_UILIMIT_HANDLES restriction
<p>When I tried to use sandboxing I've been using for other processes to one in which I'm creating a notification tray icon, I get "invalid window handle" when calling Shell_NotifyIcon() to add the icon, unless I remove the JOB_OBJECT_UILIMIT_HANDLES from the process' job object. Microsoft states that this limit "Prevents processes associated with the job from using USER handles owned by processes not associated with the same job." So how does this apply here? The window handle I pass into the notify icon structure is of a window created by the process itself. Is Shell_NotifyIcon() internally accessing some other USER object handle? Microsoft also states that UserHandleGrantAccess() can be used to bypass the restriction for individual handles, but, again, I don't know which handle is the issue.
(Note: I'm also aware that Shell_NotifyIcon() doesn't reliably set the last error, so "invalid window handle" could be misleading).</p>