public unsafe static void UsingManifestDo(string manifest, Action action) { fixed(char *lpSource = manifest) { var context = new ACTCTXW { cbSize = (uint)sizeof(ACTCTXW), lpSource = lpSource }; IntPtr hActCtx = CreateActCtxW(ref context); if (hActCtx == (IntPtr)(-1)) { throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); } try { IntPtr cookie = IntPtr.Zero; if (ActivateActCtx(hActCtx, out cookie).IsFalse()) { throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); } try { action(); } finally { DeactivateActCtx(0, cookie); } } finally { ReleaseActCtx(hActCtx); } } }
public unsafe extern static IntPtr CreateActCtxW(ref ACTCTXW pActCtx);
internal static extern IntPtr CreateActCtxW([In] ACTCTXW actCtx);
public static unsafe partial IntPtr CreateActCtxW(ref ACTCTXW pActCtx);