├── src
├── VirtualDesktop (LocalAppData).lnk
├── VirtualDesktop.WPF
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── VirtualDesktop.WPF.csproj
│ ├── ApplicationExtensions.cs
│ └── WindowExtensions.cs
├── VirtualDesktop.WinForms
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── FormExtensions.cs
│ └── VirtualDesktop.WinForms.csproj
├── VirtualDesktop
│ ├── Interop
│ │ ├── Proxy
│ │ │ ├── IApplicationViewCollection.cs
│ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ ├── IApplicationView.cs
│ │ │ ├── IVirtualDesktop.cs
│ │ │ ├── IVirtualDesktopPinnedApps.cs
│ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ └── IVirtualDesktopNotification.cs
│ │ ├── Build10240_0000
│ │ │ ├── .interfaces
│ │ │ │ ├── IVirtualDesktop.cs
│ │ │ │ ├── AssemblyInfo.cs
│ │ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ │ ├── IVirtualDesktopPinnedApps.cs
│ │ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ │ ├── IApplicationViewCollection.cs
│ │ │ │ ├── IVirtualDesktopNotification.cs
│ │ │ │ └── IApplicationView.cs
│ │ │ ├── ApplicationView.cs
│ │ │ ├── VirtualDesktop.cs
│ │ │ ├── ApplicationViewCollection.cs
│ │ │ ├── VirtualDesktopPinnedApps.cs
│ │ │ ├── .Provider.cs
│ │ │ ├── VirtualDesktopManagerInternal.cs
│ │ │ └── VirtualDesktopNotificationService.cs
│ │ ├── Build20348_0000
│ │ │ ├── .interfaces
│ │ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ │ ├── IVirtualDesktop.cs
│ │ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ │ └── IVirtualDesktopNotification.cs
│ │ │ ├── VirtualDesktop.cs
│ │ │ ├── .Provider.cs
│ │ │ ├── VirtualDesktopManagerInternal.cs
│ │ │ └── VirtualDesktopNotificationService.cs
│ │ ├── Build22000_0000
│ │ │ ├── .interfaces
│ │ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ │ ├── IVirtualDesktop.cs
│ │ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ │ └── IVirtualDesktopNotification.cs
│ │ │ ├── VirtualDesktop.cs
│ │ │ ├── .Provider.cs
│ │ │ ├── VirtualDesktopManagerInternal.cs
│ │ │ └── VirtualDesktopNotificationService.cs
│ │ ├── Build22621_2215
│ │ │ ├── .interfaces
│ │ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ │ ├── IVirtualDesktop.cs
│ │ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ │ └── IVirtualDesktopNotification.cs
│ │ │ ├── VirtualDesktop.cs
│ │ │ ├── .Provider.cs
│ │ │ ├── VirtualDesktopManagerInternal.cs
│ │ │ └── VirtualDesktopNotificationService.cs
│ │ ├── Build26100_0000
│ │ │ ├── .interfaces
│ │ │ │ ├── IVirtualDesktopNotificationService.cs
│ │ │ │ ├── IVirtualDesktop.cs
│ │ │ │ ├── IVirtualDesktopManagerInternal.cs
│ │ │ │ └── IVirtualDesktopNotification.cs
│ │ │ ├── VirtualDesktop.cs
│ │ │ ├── .Provider.cs
│ │ │ ├── VirtualDesktopManagerInternal.cs
│ │ │ └── VirtualDesktopNotificationService.cs
│ │ ├── HResult.cs
│ │ ├── CLSID.cs
│ │ ├── HString.cs
│ │ ├── ComWrapperFactory.cs
│ │ ├── ComInterfaceAttribute.cs
│ │ ├── Win32.cs
│ │ ├── ComInterfaceAssembly.cs
│ │ ├── VirtualDesktopProvider.cs
│ │ ├── ComWrapperBase.cs
│ │ ├── IID.cs
│ │ └── ComInterfaceAssemblyBuilder.cs
│ ├── VirtualDesktopExtensions.cs
│ ├── Utils
│ │ ├── TransparentWindow.cs
│ │ ├── Disposable.cs
│ │ ├── OS.cs
│ │ ├── ExplorerRestartListenerWindow.cs
│ │ └── RawWindow.cs
│ ├── Properties
│ │ ├── Configurations.cs
│ │ └── AssemblyInfo.cs
│ ├── VirtualDesktop.csproj.DotSettings
│ ├── VirtualDesktopEventArgs.cs
│ ├── VirtualDesktop.system.cs
│ ├── VirtualDesktop.csproj
│ ├── VirtualDesktop.notification.cs
│ └── app.config
├── Directory.Build.props
└── VirtualDesktop.sln
├── .github
├── pack.bat
├── workflows
│ ├── build.yml
│ └── publish.yml
└── FUNDING.yml
├── .editorconfig
├── samples
├── VirtualDesktop.Showcase
│ ├── App.xaml.cs
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── App.xaml
│ ├── VirtualDesktop.Showcase.csproj
│ └── MainWindow.xaml
└── README.md
├── LICENSE
├── .gitattributes
├── .gitignore
└── README.md
/src/VirtualDesktop (LocalAppData).lnk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Slion/VirtualDesktop/HEAD/src/VirtualDesktop (LocalAppData).lnk
--------------------------------------------------------------------------------
/.github/pack.bat:
--------------------------------------------------------------------------------
1 | dotnet build ..\src\VirtualDesktop.sln -c Release
2 | dotnet pack ..\src\VirtualDesktop.sln -c Release --no-build -o %CD%
3 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.{cs,xaml}]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = crlf
7 | insert_final_newline = true
8 | charset = utf-8-bom
9 |
--------------------------------------------------------------------------------
/src/VirtualDesktop.WPF/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("9dd597c6-065a-4764-a96c-1b18c4eded78")]
5 |
--------------------------------------------------------------------------------
/src/VirtualDesktop.WinForms/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | [assembly: ComVisible(false)]
4 | [assembly: Guid("da586cec-2ffe-42c5-aeda-56d25984c7ad")]
5 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Proxy/IApplicationViewCollection.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop.Proxy;
2 |
3 | [ComInterface]
4 | public interface IApplicationViewCollection
5 | {
6 | IApplicationView GetViewForHwnd(IntPtr hWnd);
7 | }
8 |
--------------------------------------------------------------------------------
/samples/VirtualDesktop.Showcase/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 |
6 | namespace VirtualDesktopShowcase;
7 |
8 | partial class App
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Proxy/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop.Proxy;
2 |
3 | [ComInterface]
4 | public interface IVirtualDesktopNotificationService
5 | {
6 | IDisposable Register(IVirtualDesktopNotification proxy);
7 | }
8 |
--------------------------------------------------------------------------------
/samples/README.md:
--------------------------------------------------------------------------------
1 | ## Samples
2 |
3 | * [VirtualDesktop.Showcase](VirtualDesktop.Showcase) … A simple application uses the VirtualDesktop library, included in this repository.
4 | * [SylphyHorn](https://github.com/Grabacr07/SylphyHorn) … Utility app for Windows by the same author.
5 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Proxy/IApplicationView.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop.Proxy;
2 |
3 | [ComInterface]
4 | public interface IApplicationView
5 | {
6 | IntPtr GetThumbnailWindow();
7 |
8 | string GetAppUserModelId();
9 |
10 | Guid GetVirtualDesktopId();
11 | }
12 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Proxy/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop.Proxy;
2 |
3 | [ComInterface]
4 | public interface IVirtualDesktop
5 | {
6 | bool IsViewVisible(IntPtr hWnd);
7 |
8 | Guid GetID();
9 |
10 | string GetName();
11 |
12 | string GetWallpaperPath();
13 | }
14 |
--------------------------------------------------------------------------------
/samples/VirtualDesktop.Showcase/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using System.Windows;
3 |
4 | [assembly: ComVisible(false)]
5 | [assembly: Guid("5B4544B8-3EF0-4E9F-8D60-DD605AD99725")]
6 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
7 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/VirtualDesktopExtensions.cs:
--------------------------------------------------------------------------------
1 | using WindowsDesktop.Interop;
2 | using WindowsDesktop.Interop.Proxy;
3 |
4 | namespace WindowsDesktop;
5 |
6 | public static class VirtualDesktopExtensions
7 | {
8 | internal static VirtualDesktop ToVirtualDesktop(this IVirtualDesktop desktop)
9 | => VirtualDesktop.FromComObject(desktop);
10 | }
11 |
--------------------------------------------------------------------------------
/samples/VirtualDesktop.Showcase/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Proxy/IVirtualDesktopPinnedApps.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop.Proxy;
2 |
3 | [ComInterface]
4 | public interface IVirtualDesktopPinnedApps
5 | {
6 | bool IsAppIdPinned(string appId);
7 |
8 | void PinAppID(string appId);
9 |
10 | void UnpinAppID(string appId);
11 |
12 | bool IsViewPinned(IntPtr hWnd);
13 |
14 | void PinView(IntPtr hWnd);
15 |
16 | void UnpinView(IntPtr hWnd);
17 | }
18 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/.interfaces/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build10240
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktop
10 | {
11 | bool IsViewVisible(IApplicationView view);
12 |
13 | Guid GetID();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/.interfaces/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | [assembly: AssemblyTitle("VirtualDesktop.{OS_BUILD}.generated")]
5 | [assembly: AssemblyCompany("grabacr.net")]
6 | [assembly: AssemblyProduct("VirtualDesktop")]
7 | [assembly: AssemblyDescription("COM interface definitions for virtual desktop on Windows 11 build {VERSION}.")]
8 | [assembly: AssemblyCopyright("Copyright © 2022 Manato KAMEYA")]
9 |
10 | [assembly: AssemblyVersion("{ASSEMBLY_VERSION}")]
11 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Utils/TransparentWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Interop;
5 |
6 | namespace WindowsDesktop.Utils;
7 |
8 | internal class TransparentWindow : RawWindow
9 | {
10 | public override void Show()
11 | {
12 | var parameters = new HwndSourceParameters(this.Name)
13 | {
14 | Width = 1,
15 | Height = 1,
16 | WindowStyle = 0x800000,
17 | };
18 |
19 | this.Show(parameters);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/.interfaces/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build10240
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopNotificationService
10 | {
11 | uint Register(IVirtualDesktopNotification pNotification);
12 |
13 | void Unregister(uint dwCookie);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build20348_0000/.interfaces/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build20348
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopNotificationService
10 | {
11 | uint Register(IVirtualDesktopNotification pNotification);
12 |
13 | void Unregister(uint dwCookie);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build22000_0000/.interfaces/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build22000
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopNotificationService
10 | {
11 | uint Register(IVirtualDesktopNotification pNotification);
12 |
13 | void Unregister(uint dwCookie);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build22621_2215/.interfaces/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build22621
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopNotificationService
10 | {
11 | uint Register(IVirtualDesktopNotification pNotification);
12 |
13 | void Unregister(uint dwCookie);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build26100_0000/.interfaces/IVirtualDesktopNotificationService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build26100
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopNotificationService
10 | {
11 | uint Register(IVirtualDesktopNotification pNotification);
12 |
13 | void Unregister(uint dwCookie);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build20348_0000/.interfaces/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsDesktop.Interop.Build10240;
4 |
5 | namespace WindowsDesktop.Interop.Build20348
6 | {
7 | [ComImport]
8 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
9 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
10 | public interface IVirtualDesktop
11 | {
12 | bool IsViewVisible(IApplicationView view);
13 |
14 | Guid GetID();
15 |
16 | IntPtr GetMonitor(IntPtr monitor);
17 |
18 | HString GetName();
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Utils/Disposable.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Utils
2 | {
3 | internal class Disposable
4 | {
5 | public static IDisposable Create(Action dispose)
6 | {
7 | return new AnonymousDisposable(dispose);
8 | }
9 |
10 | private class AnonymousDisposable : IDisposable
11 | {
12 | private bool _isDisposed;
13 | private readonly Action _dispose;
14 |
15 | public AnonymousDisposable(Action dispose)
16 | {
17 | this._dispose = dispose;
18 | }
19 |
20 | public void Dispose()
21 | {
22 | if (this._isDisposed) return;
23 |
24 | this._isDisposed = true;
25 | this._dispose();
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build22000_0000/.interfaces/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsDesktop.Interop.Build10240;
4 |
5 | namespace WindowsDesktop.Interop.Build22000
6 | {
7 | [ComImport]
8 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
9 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
10 | public interface IVirtualDesktop
11 | {
12 | bool IsViewVisible(IApplicationView view);
13 |
14 | Guid GetID();
15 |
16 | IntPtr Proc5();
17 |
18 | HString GetName();
19 |
20 | HString GetWallpaperPath();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/samples/VirtualDesktop.Showcase/VirtualDesktop.Showcase.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | WinExe
5 | net8.0-windows10.0.19041.0;net7.0-windows10.0.19041.0;net6.0-windows10.0.19041.0
6 | true
7 | enable
8 | VirtualDesktopShowcase
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build22621_2215/.interfaces/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsDesktop.Interop.Build10240;
4 |
5 | namespace WindowsDesktop.Interop.Build22621
6 | {
7 | [ComImport]
8 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
9 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
10 | public interface IVirtualDesktop
11 | {
12 | bool IsViewVisible(IApplicationView view);
13 |
14 | Guid GetID();
15 |
16 | HString GetName();
17 |
18 | HString GetWallpaperPath();
19 |
20 | bool IsRemote();
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build26100_0000/.interfaces/IVirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 | using WindowsDesktop.Interop.Build10240;
4 |
5 | namespace WindowsDesktop.Interop.Build26100
6 | {
7 | [ComImport]
8 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
9 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
10 | public interface IVirtualDesktop
11 | {
12 | bool IsViewVisible(IApplicationView view);
13 |
14 | Guid GetID();
15 |
16 | HString GetName();
17 |
18 | HString GetWallpaperPath();
19 |
20 | bool IsRemote();
21 |
22 |
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/HResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace WindowsDesktop.Interop;
5 |
6 | internal enum HResult : uint
7 | {
8 | // ReSharper disable IdentifierTypo
9 | TYPE_E_OUTOFBOUNDS = 0x80028CA1,
10 | TYPE_E_ELEMENTNOTFOUND = 0x8002802B,
11 | REGDB_E_CLASSNOTREG = 0x80040154,
12 | RPC_S_SERVER_UNAVAILABLE = 0x800706BA,
13 | // ReSharper restore IdentifierTypo
14 | }
15 |
16 | internal static class HResultExtensions
17 | {
18 | public static bool Match(this Exception ex, params HResult[] hResult)
19 | {
20 | return hResult
21 | .Cast()
22 | .Any(x => (uint)ex.HResult == x);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/CLSID.cs:
--------------------------------------------------------------------------------
1 | namespace WindowsDesktop.Interop;
2 |
3 | // ReSharper disable once InconsistentNaming
4 | internal static class CLSID
5 | {
6 | public static Guid ImmersiveShell { get; } = new("c2f03a33-21f5-47fa-b4bb-156362a2f239");
7 |
8 | public static Guid VirtualDesktopManager { get; } = new("aa509086-5ca9-4c25-8f95-589d3c07b48a");
9 |
10 | public static Guid VirtualDesktopManagerInternal { get; } = new("c5e0cdca-7b6e-41b2-9fc4-d93975cc467b");
11 |
12 | public static Guid VirtualDesktopNotificationService { get; } = new Guid("a501fdec-4a09-464c-ae4e-1b9c21b84918");
13 |
14 | public static Guid VirtualDesktopPinnedApps { get; } = new("b5a399e7-1c87-46b8-88e9-fc5747b171bd");
15 | }
16 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/.interfaces/IVirtualDesktopPinnedApps.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace WindowsDesktop.Interop.Build10240
5 | {
6 | [ComImport]
7 | [Guid("00000000-0000-0000-0000-000000000000") /* replace at runtime */]
8 | [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
9 | public interface IVirtualDesktopPinnedApps
10 | {
11 | bool IsAppIdPinned(string appId);
12 |
13 | void PinAppID(string appId);
14 |
15 | void UnpinAppID(string appId);
16 |
17 | bool IsViewPinned(IApplicationView applicationView);
18 |
19 | void PinView(IApplicationView applicationView);
20 |
21 | void UnpinView(IApplicationView applicationView);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 |
9 |
10 | env:
11 | DOTNET_VERSION: 8.0.x
12 | BUILD_TARGET: .\src\VirtualDesktop.sln
13 |
14 |
15 | jobs:
16 | build:
17 | name: .NET Build
18 | runs-on: windows-latest
19 | # Don't build for release the publish workflow will do that to
20 | if: "!startsWith(github.event.head_commit.message, 'Release v')"
21 |
22 | steps:
23 | - uses: actions/checkout@v4
24 |
25 | - name: Use .NET ${{ env.DOTNET_VERSION }}
26 | uses: actions/setup-dotnet@v4
27 | with:
28 | dotnet-version: ${{ env.DOTNET_VERSION }}
29 |
30 | - name: Build
31 | run: dotnet build ${{ env.BUILD_TARGET }} -c Release
32 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/ApplicationView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using WindowsDesktop.Interop.Proxy;
5 |
6 | namespace WindowsDesktop.Interop.Build10240;
7 |
8 | internal class ApplicationView : ComWrapperBase, IApplicationView
9 | {
10 | public ApplicationView(ComInterfaceAssembly assembly, object comObject)
11 | : base(assembly, comObject)
12 | {
13 | }
14 |
15 | public IntPtr GetThumbnailWindow()
16 | => this.InvokeMethod();
17 |
18 | public string GetAppUserModelId()
19 | => this.InvokeMethod() ?? throw new Exception("Failed to get AppUserModelId.");
20 |
21 | public Guid GetVirtualDesktopId()
22 | => this.InvokeMethod();
23 | }
24 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/HString.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 | using WinRT;
3 |
4 | namespace WindowsDesktop.Interop;
5 |
6 | // ## Note
7 | // .NET 5 has removed WinRT support, so HString cannot marshal to System.String.
8 | // Since marshalling with UnmanagedType.HString fails, use IntPtr to get the string via C#/WinRT MarshalString.
9 | //
10 | // see also: https://github.com/microsoft/CsWinRT/blob/master/docs/interop.md
11 |
12 | [StructLayout(LayoutKind.Sequential)]
13 | public struct HString
14 | {
15 | private readonly IntPtr _abi;
16 |
17 | internal HString(string str)
18 | {
19 | this._abi = MarshalString.GetAbi(MarshalString.CreateMarshaler(str));
20 | }
21 |
22 | public static implicit operator string(HString hStr)
23 | => MarshalString.FromAbi(hStr._abi);
24 | }
25 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/VirtualDesktop.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using WindowsDesktop.Interop.Proxy;
5 |
6 | namespace WindowsDesktop.Interop.Build10240;
7 |
8 | internal class VirtualDesktop : ComWrapperBase, IVirtualDesktop
9 | {
10 | private Guid? _id;
11 |
12 | public VirtualDesktop(ComInterfaceAssembly assembly, object comObject)
13 | : base(assembly, comObject)
14 | {
15 | }
16 |
17 | public bool IsViewVisible(IntPtr hWnd)
18 | => this.InvokeMethod(Args(hWnd));
19 |
20 | public Guid GetID()
21 | => this._id ?? (Guid)(this._id = this.InvokeMethod());
22 |
23 | public string GetName()
24 | => "";
25 |
26 | public string GetWallpaperPath()
27 | => "";
28 | }
29 |
--------------------------------------------------------------------------------
/src/VirtualDesktop/Interop/Build10240_0000/ApplicationViewCollection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using WindowsDesktop.Interop.Proxy;
3 |
4 | namespace WindowsDesktop.Interop.Build10240;
5 |
6 | internal class ApplicationViewCollection : ComWrapperBase, IApplicationViewCollection
7 | {
8 | public ApplicationViewCollection(ComInterfaceAssembly assembly)
9 | : base(assembly)
10 | {
11 | }
12 |
13 | public ApplicationView GetViewForHwnd(IntPtr hWnd)
14 | {
15 | var view = this.InvokeMethod