Example #1
0
        internal static void CreateCorrectActivationContext()
        {
            NativeMethods.ACTCTXW actCtx = new NativeMethods.ACTCTXW();
            actCtx.cbSize = (uint)Marshal.SizeOf(typeof(NativeMethods.ACTCTXW));

            // Get HINSTANCE to the current assembly, in which we've embedded
            // our assembly manifest
            Module m         = typeof(DllVersionManager).Module;
            IntPtr hInstance = Marshal.GetHINSTANCE(m);

            actCtx.dwFlags =
                (int)NativeMethods.ACTCTXFlags.ACTCTX_FLAG_RESOURCE_NAME_VALID;
            //actCtx.hModule = hInstance;
            actCtx.lpSource       = "c:\\Users\\jeffchri\\Documents\\Visual Studio 2005\\Projects\\NTSDK\\VistaBridge\\VistaBridgeLibrary\\bin\\Debug\\VistaBridgeLibrary.dll";
            actCtx.lpResourceName = 17;

            IntPtr hContext = UnsafeNativeMethods.CreateActCtx(ref actCtx);

            if (hContext == ((IntPtr)(-1)))
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            bool success = UnsafeNativeMethods.ActivateActCtx(ref actCtx, ref activationContextCookie);

            if (!success)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
        }
Example #2
0
        internal static void CreateCorrectActivationContext()
        {
            NativeMethods.ACTCTXW actCtx = new NativeMethods.ACTCTXW();
            actCtx.cbSize = (uint)Marshal.SizeOf(typeof(NativeMethods.ACTCTXW));
            
            // Get HINSTANCE to the current assembly, in which we've embedded
            // our assembly manifest
            Module m = typeof(DllVersionManager).Module;
            IntPtr hInstance = Marshal.GetHINSTANCE(m);

            actCtx.dwFlags =
                (int)NativeMethods.ACTCTXFlags.ACTCTX_FLAG_RESOURCE_NAME_VALID;
            //actCtx.hModule = hInstance;
            actCtx.lpSource = "c:\\Users\\jeffchri\\Documents\\Visual Studio 2005\\Projects\\NTSDK\\VistaBridge\\VistaBridgeLibrary\\bin\\Debug\\VistaBridgeLibrary.dll";
            actCtx.lpResourceName = 17;

            IntPtr hContext = UnsafeNativeMethods.CreateActCtx(ref actCtx);
            if (hContext == ((IntPtr)(-1)))
                throw new Win32Exception(Marshal.GetLastWin32Error());
            bool success = UnsafeNativeMethods.ActivateActCtx(ref actCtx, ref activationContextCookie);
            if (!success)
                throw new Win32Exception(Marshal.GetLastWin32Error());

        }
Example #3
0
 internal static extern bool ActivateActCtx(
     [In, Out] ref NativeMethods.ACTCTXW pActCtx,
     [In, Out] ref IntPtr lpCookie);
Example #4
0
 internal static extern IntPtr CreateActCtx([In] ref NativeMethods.ACTCTXW pActCtx);