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); }
internal static extern object CoGetObject( string pszName, [In] ref BIND_OPTS3 pBindOptions, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
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); }