public static ActiveDesktopWrapper Factory() { ActiveDesktopWrapper adw = new ActiveDesktopWrapper(); adw.ApplyChanges = adw.DelegationFactory(0); adw.GetWallpaper = adw.DelegationFactory(1); adw.SetWallpaper = adw.DelegationFactory(2); adw.GetWallpaperOptions = adw.DelegationFactory(3); adw.SetWallpaperOptions = adw.DelegationFactory(4); adw.GetPattern = adw.DelegationFactory(5); adw.SetPattern = adw.DelegationFactory(6); adw.GetDesktopItemOptions = adw.DelegationFactory(7); adw.SetDesktopItemOptions = adw.DelegationFactory(8); adw.AddDesktopItem = adw.DelegationFactory(9); adw.AddDesktopItemWithUI = adw.DelegationFactory(10); adw.ModifyDesktopItem = adw.DelegationFactory(11); adw.RemoveDesktopItem = adw.DelegationFactory(12); adw.GetDesktopItemCount = adw.DelegationFactory(13); adw.GetDesktopItem = adw.DelegationFactory(14); adw.GetDesktopItemByID = adw.DelegationFactory(15); adw.GenerateDesktopItemHtml = adw.DelegationFactory(16); adw.AddUrl = adw.DelegationFactory(17); adw.GetDesktopItemBySource = adw.DelegationFactory(18); Thread server = new Thread(new ThreadStart(adw.ProduceThread)); server.SetApartmentState(ApartmentState.STA); server.Start(); return(adw); }
public void SetWallpaper(string imagePath) { ThreadStart threadStarter = () => { IActiveDesktop _activeDesktop = ActiveDesktopWrapper.GetActiveDesktop(); _activeDesktop.SetWallpaper(imagePath, 0); _activeDesktop.ApplyChanges(AD_Apply.ALL | AD_Apply.FORCE); Marshal.ReleaseComObject(_activeDesktop); }; Thread thread = new Thread(threadStarter); thread.SetApartmentState(ApartmentState.STA); // Set the thread to STA (required!) thread.Start(); thread.Join(2000); }
public async Task <object> Invoke(object input) { return(ActiveDesktopWrapper.Factory()); }