示例#1
0
        public static object RunElevatedComObject(Guid Clsid, Guid InterfaceID)
        {
            string CLSID = Clsid.ToString("B");             // B formatting directive: returns {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

            string     monikerName = "Elevation:Administrator!new:" + CLSID;
            BIND_OPTS3 bo          = new BIND_OPTS3();

            bo.cbStruct       = (uint)Marshal.SizeOf(bo);
            bo.hwnd           = IntPtr.Zero;
            bo.dwClassContext = (int)CLSCTX.CLSCTX_ALL;
            object retVal = NativeMethods.CoGetObject(monikerName, ref bo, InterfaceID);

            return(retVal);
        }
示例#2
0
 internal static extern object CoGetObject(
     string pszName,
     [In] ref BIND_OPTS3 pBindOptions,
     [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
示例#3
0
 public static object RunElevatedComObject(Guid Clsid, Guid InterfaceID)
 {
     string CLSID = Clsid.ToString("B"); // B formatting directive: returns {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
     string monikerName = "Elevation:Administrator!new:" + CLSID;
     BIND_OPTS3 bo = new BIND_OPTS3();
     bo.cbStruct = (uint)Marshal.SizeOf(bo);
     bo.hwnd = IntPtr.Zero;
     bo.dwClassContext = (int)CLSCTX.CLSCTX_ALL;
     object retVal = NativeMethods.CoGetObject(monikerName, ref bo, InterfaceID);
     return (retVal);
 }