示例#1
0
        static internal object LaunchElevatedCOMObject(Guid Clsid, Guid InterfaceID)
        {
            string CLSID = Clsid.ToString("B"); // B formatting directive: returns {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} 
            string monikerName = "Elevation:Administrator!new:" + CLSID;

            NativeMethods.BIND_OPTS3 bo = new NativeMethods.BIND_OPTS3();
            bo.cbStruct = (uint)Marshal.SizeOf(bo);
            bo.hwnd = IntPtr.Zero;
            bo.dwClassContext = (int)NativeMethods.CLSCTX.CLSCTX_ALL;

            object retVal = UnsafeNativeMethods.CoGetObject(monikerName, ref bo, InterfaceID);

            return (retVal);
        }
示例#2
0
 internal static extern object CoGetObject(
     string pszName,
     [In] ref NativeMethods.BIND_OPTS3 pBindOptions,
     [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);