public override void Call() { if (args.Length == 2) { IntPtr outty = new IntPtr(Convert.ToInt32(args[1].value)); AssemblerExecute.registers.EAX = Kernel32.ActivateActCtx(new IntPtr(Convert.ToInt32(args[0].value)), out outty) ? 1 : 0; } }
/// <summary> /// Activate() does nothing if a theming context is already active on the current thread, which is good /// for perf reasons. However, in some cases, like in the Timer callback, we need to put another context /// on the stack even if one is already present. In such cases, this method helps - you get to manage /// the cookie yourself though. /// </summary> public static IntPtr Activate() { if (IsContextActiveButNotCreated() && Kernel32.ActivateActCtx(s_hActCtx, out IntPtr userCookie)) { return(userCookie); } return(IntPtr.Zero); }
/// <summary> /// Activate() does nothing if a theming context is already active on the current thread, which is good /// for perf reasons. However, in some cases, like in the Timer callback, we need to put another context /// on the stack even if one is already present. In such cases, this method helps - you get to manage /// the cookie yourself though. /// </summary> public static IntPtr Activate(bool useVisualStyles) { if (IsContextActiveButNotCreated(useVisualStyles) && Kernel32.ActivateActCtx(s_hActCtx, out IntPtr userCookie).IsTrue()) { return(userCookie); } return(IntPtr.Zero); }
private unsafe void ExecuteWithActivationContext(string applicationManifest, Action action) { var context = new Kernel32.ACTCTXW(); IntPtr handle; fixed(char *p = applicationManifest) { context.cbSize = (uint)sizeof(Kernel32.ACTCTXW); context.lpSource = p; handle = Kernel32.CreateActCtxW(ref context); } if (handle == IntPtr.Zero) { throw new Win32Exception(); } try { if (Kernel32.ActivateActCtx(handle, out var cookie).IsFalse()) { throw new Win32Exception(); } try { action(); } finally { if (Kernel32.DeactivateActCtx(0, cookie).IsFalse()) { throw new Win32Exception(); } } } finally { ReleaseActCtx(handle); } }