Ejemplo n.º 1
0
        //-----------------------------------------------------------------------------------------------------------------------
        /// <summary>
        ///   Sets the wallpaper to the given <paramref name="fileName"/> for each monitor.
        /// </summary>
        ///
        /// <exception cref="COMException">Could not create or interact with the required COM object.</exception>
        //-----------------------------------------------------------------------------------------------------------------------
        public static void SetWallpaper(string fileName, DESKTOP_WALLPAPER_POSITION position)
        {
            if (mIDesktopWallpaper == null)
            {
                throw new COMException("Could not create IDesktopWallpaper COM object.");
            }

            try
            {
                // The first parameter indicates the monitor by its identifier (obtained with GetMonitorDevicePathAt) and the
                // second a path to the wallpaper. If NULL is passed as the monitor identifier to SetWallpaper, then that
                // wallpaper will be set for all monitors.
                mIDesktopWallpaper.SetWallpaper(null, fileName);
                mIDesktopWallpaper.SetPosition(position);
            }
            catch (COMException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new COMException("Could not interact with the IDesktopWallpaper COM object.", e);
            }
        }
Ejemplo n.º 2
0
 internal static Fit ToFit(this DESKTOP_WALLPAPER_POSITION position)
 {
     return((Fit)position);
 }
 public HRESULT SetPosition(DESKTOP_WALLPAPER_POSITION position)
 {
     return(((delegate * unmanaged <IDesktopWallpaper *, DESKTOP_WALLPAPER_POSITION, int>)(lpVtbl[10]))((IDesktopWallpaper *)Unsafe.AsPointer(ref this), position));
 }