Grabacr07 / VirtualDesktop

C# wrapper for the Virtual Desktop API on Windows 11.
MIT License
631 stars 135 forks source link

Not working with Windows 11 22H2 ? #76

Open 3dtoall opened 2 years ago

3dtoall commented 2 years ago

Works on Windows 10. Testing on Windows 11 22H2, I get this error: w11_22H2_error

Dexterously commented 2 years ago

Me too

aquafir commented 2 years ago

Looks like this is due to missing CLSIDs and possibly the addition of [GetAllCurrentDesktops](https://github.com/newlooper/VirtualSpace/blob/main/VirtualDesktop11/COM.cs#L173)?

Newlooper's VirtualSpace runs correctly so I hoped plugging in the guids from there would work. I tried adding them for my OS version (22621, but 22H2 is >22489?):

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <string>IApplicationView,{372E1D3B-38D3-42E4-A15B-8AB2B178F513}</string>
    <string>IApplicationViewCollection,{1841C6D7-4F9D-42C0-AF41-8747538F10E5}</string>
    <string>IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}</string>
    <string>IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA}</string>
    <string>IVirtualDesktop,{536D3495-B208-4CC9-AE26-DE8111275BF8}</string>
    <string>IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}</string>
    <string>IVirtualDesktopManagerInternal,{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}</string>
    <string>IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8}</string>
    <string>IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf}</string>
    <string>IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F}</string>
</ArrayOfString>

That leaves the demo with a null reference at GetDesktops()

kenykau commented 2 years ago

After comparing the codes with VirtualSpace

/////////////////////////////////////////////////////////////////
        // COM Interface "B2F925B9-5A0F-4D2E-9F4D-2B1507593C10"
        // for windows 11 22H2 (>22489) COM Interface require this func.
        // for windows 11 21H2 (22000.xxx) this func must be commented
        IObjectArray GetAllCurrentDesktops();
        void GetDesktops( IntPtr hWndOrMon, out IObjectArray desktops );

I tried to add

IObjectArray GetAllCurrentDesktops();

Problem solved. I can run for 22H2

Please try

patriq commented 2 years ago

@kenykau Can you share the patch of your changes specifically? I tried adding IObjectArray GetAllCurrentDesktops(); with no luck.

patriq commented 2 years ago
Index: src/VirtualDesktop/Properties/Settings.Designer.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/VirtualDesktop/Properties/Settings.Designer.cs b/src/VirtualDesktop/Properties/Settings.Designer.cs
--- a/src/VirtualDesktop/Properties/Settings.Designer.cs    (revision a6c69e420307e0717f296501c1e7595977e27b6b)
+++ b/src/VirtualDesktop/Properties/Settings.Designer.cs    (date 1664652742667)
@@ -1,10 +1,10 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
-//     このコードはツールによって生成されました。
-//     ランタイム バージョン:4.0.30319.42000
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.42000
 //
-//     このファイルへの変更は、以下の状況下で不正な動作の原因になったり、
-//     コードが再生成されるときに損失したりします。
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
 // </auto-generated>
 //------------------------------------------------------------------------------

@@ -12,7 +12,7 @@

     [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
-    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
     internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {

         private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -85,5 +85,14 @@
                 return ((global::System.Collections.Specialized.StringCollection)(this["v_22000"]));
             }
         }
+        
+        [global::System.Configuration.ApplicationScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?> <ArrayOfString xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">    <string>IApplicationView,{372E1D3B-38D3-42E4-A15B-8AB2B178F513}</string>    <string>IApplicationViewCollection,{1841C6D7-4F9D-42C0-AF41-8747538F10E5}</string>  <string>IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}</string>    <string>IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA}</string>    <string>IVirtualDesktop,{536D3495-B208-4CC9-AE26-DE8111275BF8}</string>     <string>IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}</string>  <string>IVirtualDesktopManagerInternal,{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}</string>  <string>IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8}</string>     <string>IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf}</string>  <string>IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F}</string> </ArrayOfString>")]
+        public global::System.Collections.Specialized.StringCollection v_22621 {
+            get {
+                return ((global::System.Collections.Specialized.StringCollection)(this["v_22621"]));
+            }
+        }
     }
 }
Index: src/VirtualDesktop/Interop/Build22000/.interfaces/IVirtualDesktopManagerInternal.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/VirtualDesktop/Interop/Build22000/.interfaces/IVirtualDesktopManagerInternal.cs b/src/VirtualDesktop/Interop/Build22000/.interfaces/IVirtualDesktopManagerInternal.cs
--- a/src/VirtualDesktop/Interop/Build22000/.interfaces/IVirtualDesktopManagerInternal.cs   (revision a6c69e420307e0717f296501c1e7595977e27b6b)
+++ b/src/VirtualDesktop/Interop/Build22000/.interfaces/IVirtualDesktopManagerInternal.cs   (date 1664654867843)
@@ -17,6 +17,8 @@

         IVirtualDesktop GetCurrentDesktop(IntPtr hWndOrMon);

+        IObjectArray GetAllCurrentDesktops();
+
         IObjectArray GetDesktops(IntPtr hWndOrMon);

         IVirtualDesktop GetAdjacentDesktop(IVirtualDesktop pDesktopReference, int uDirection);
Index: src/VirtualDesktop/app.config
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/VirtualDesktop/app.config b/src/VirtualDesktop/app.config
--- a/src/VirtualDesktop/app.config (revision a6c69e420307e0717f296501c1e7595977e27b6b)
+++ b/src/VirtualDesktop/app.config (date 1664652742667)
@@ -1,60 +1,60 @@
 <?xml version="1.0" encoding="utf-8"?>
 <configuration>
-  <configSections>
-    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-      <section name="WindowsDesktop.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
-    </sectionGroup>
-  </configSections>
-  <applicationSettings>
-    <WindowsDesktop.Properties.Settings>
-      <setting name="v_17134" serializeAs="Xml">
-        <value>
-          <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-            <string>IApplicationView,{871F602A-2B58-42B4-8C4B-6C43D642C06F}</string>
-            <string>IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} </string>
-            <string>IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} </string>
-            <string>IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} </string>
-            <string>IVirtualDesktop,{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4} </string>
-            <string>IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B} </string>
-            <string>IVirtualDesktopManagerInternal,{F31574D6-B682-4CDC-BD56-1827860ABEC6} </string>
-            <string>IVirtualDesktopNotification,{C179334C-4295-40D3-BEA1-C654D965605A} </string>
-            <string>IVirtualDesktopNotificationService,{0CD45E71-D927-4F15-8B0A-8FEF525337BF} </string>
-            <string>IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F} </string>
-          </ArrayOfString>
-        </value>
-      </setting>
-      <setting name="v_16299" serializeAs="Xml">
-        <value>
-          <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-            <string>IApplicationView,{9AC0B5C8-1484-4C5B-9533-4134A0F97CEA} </string>
-            <string>IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} </string>
-            <string>IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} </string>
-            <string>IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} </string>
-            <string>IVirtualDesktop,{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4} </string>
-            <string>IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B} </string>
-            <string>IVirtualDesktopManagerInternal,{F31574D6-B682-4CDC-BD56-1827860ABEC6} </string>
-            <string>IVirtualDesktopNotification,{C179334C-4295-40D3-BEA1-C654D965605A} </string>
-            <string>IVirtualDesktopNotificationService,{0CD45E71-D927-4F15-8B0A-8FEF525337BF} </string>
-            <string>IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F} </string>
-          </ArrayOfString>
-        </value>
-      </setting>
-      <setting name="v_22000" serializeAs="Xml">
-        <value>
-          <ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-            <string>IApplicationView,{372e1d3b-38d3-42e4-a15b-8ab2b178f513} </string>
-            <string>IApplicationViewCollection,{1841c6d7-4f9d-42c0-af41-8747538f10e5} </string>
-            <string>IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} </string>
-            <string>IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} </string>
-            <string>IVirtualDesktop,{536d3495-b208-4cc9-ae26-de8111275bf8} </string>
-            <string>IVirtualDesktopManager,{a5cd92ff-29be-454c-8d04-d82879fb3f1b} </string>
-            <string>IVirtualDesktopManagerInternal,{b2f925b9-5a0f-4d2e-9f4d-2b1507593c10} </string>
-            <string>IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8} </string>
-            <string>IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf} </string>
-            <string>IVirtualDesktopPinnedApps,{4ce81583-1e4c-4632-a621-07a53543148f} </string>
-          </ArrayOfString>
-        </value>
-      </setting>
-    </WindowsDesktop.Properties.Settings>
-  </applicationSettings>
-</configuration>
+    <configSections>
+        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+            <section name="WindowsDesktop.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+        </sectionGroup>
+    </configSections>
+    <applicationSettings>
+        <WindowsDesktop.Properties.Settings>
+            <setting name="v_17134" serializeAs="String">
+                <value>&lt;?xml version="1.0" encoding="utf-16"?&gt;
+&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+  &lt;string&gt;IApplicationView,{871F602A-2B58-42B4-8C4B-6C43D642C06F}&lt;/string&gt;
+  &lt;string&gt;IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} &lt;/string&gt;
+  &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
+  &lt;string&gt;IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktop,{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManagerInternal,{F31574D6-B682-4CDC-BD56-1827860ABEC6} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotification,{C179334C-4295-40D3-BEA1-C654D965605A} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotificationService,{0CD45E71-D927-4F15-8B0A-8FEF525337BF} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F} &lt;/string&gt;
+&lt;/ArrayOfString&gt;</value>
+            </setting>
+            <setting name="v_16299" serializeAs="String">
+                <value>&lt;?xml version="1.0" encoding="utf-16"?&gt;
+&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+  &lt;string&gt;IApplicationView,{9AC0B5C8-1484-4C5B-9533-4134A0F97CEA} &lt;/string&gt;
+  &lt;string&gt;IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} &lt;/string&gt;
+  &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
+  &lt;string&gt;IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktop,{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManagerInternal,{F31574D6-B682-4CDC-BD56-1827860ABEC6} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotification,{C179334C-4295-40D3-BEA1-C654D965605A} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotificationService,{0CD45E71-D927-4F15-8B0A-8FEF525337BF} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F} &lt;/string&gt;
+&lt;/ArrayOfString&gt;</value>
+            </setting>
+            <setting name="v_22000" serializeAs="String">
+                <value>&lt;?xml version="1.0" encoding="utf-16"?&gt;
+&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+  &lt;string&gt;IApplicationView,{372e1d3b-38d3-42e4-a15b-8ab2b178f513} &lt;/string&gt;
+  &lt;string&gt;IApplicationViewCollection,{1841c6d7-4f9d-42c0-af41-8747538f10e5} &lt;/string&gt;
+  &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
+  &lt;string&gt;IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktop,{536d3495-b208-4cc9-ae26-de8111275bf8} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManager,{a5cd92ff-29be-454c-8d04-d82879fb3f1b} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopManagerInternal,{b2f925b9-5a0f-4d2e-9f4d-2b1507593c10} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf} &lt;/string&gt;
+  &lt;string&gt;IVirtualDesktopPinnedApps,{4ce81583-1e4c-4632-a621-07a53543148f} &lt;/string&gt;
+&lt;/ArrayOfString&gt;</value>
+            </setting>
+            <setting name="v_22621" serializeAs="String">
+                <value>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;  &lt;string&gt;IApplicationView,{372E1D3B-38D3-42E4-A15B-8AB2B178F513}&lt;/string&gt;    &lt;string&gt;IApplicationViewCollection,{1841C6D7-4F9D-42C0-AF41-8747538F10E5}&lt;/string&gt;  &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}&lt;/string&gt;    &lt;string&gt;IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA}&lt;/string&gt;    &lt;string&gt;IVirtualDesktop,{536D3495-B208-4CC9-AE26-DE8111275BF8}&lt;/string&gt;     &lt;string&gt;IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopManagerInternal,{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8}&lt;/string&gt;     &lt;string&gt;IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F}&lt;/string&gt; &lt;/ArrayOfString&gt;</value>
+            </setting>
+        </WindowsDesktop.Properties.Settings>
+    </applicationSettings>
+</configuration>
\ No newline at end of file
Index: src/VirtualDesktop/Properties/Settings.settings
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/VirtualDesktop/Properties/Settings.settings b/src/VirtualDesktop/Properties/Settings.settings
--- a/src/VirtualDesktop/Properties/Settings.settings   (revision a6c69e420307e0717f296501c1e7595977e27b6b)
+++ b/src/VirtualDesktop/Properties/Settings.settings   (date 1664652735773)
@@ -1,10 +1,10 @@
-<?xml version='1.0' encoding='utf-8'?>
+<?xml version="1.0" encoding="UTF-8"?>
 <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="WindowsDesktop.Properties" GeneratedClassName="Settings">
   <Profiles />
   <Settings>
     <Setting Name="v_17134" Type="System.Collections.Specialized.StringCollection" Scope="Application">
-      <Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
-&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+      <Value Profile="(Default)">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
+&lt;ArrayOfString xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   &lt;string&gt;IApplicationView,{871F602A-2B58-42B4-8C4B-6C43D642C06F}&lt;/string&gt;
   &lt;string&gt;IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} &lt;/string&gt;
   &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
@@ -18,8 +18,8 @@
 &lt;/ArrayOfString&gt;</Value>
     </Setting>
     <Setting Name="v_16299" Type="System.Collections.Specialized.StringCollection" Scope="Application">
-      <Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
-&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+      <Value Profile="(Default)">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
+&lt;ArrayOfString xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   &lt;string&gt;IApplicationView,{9AC0B5C8-1484-4C5B-9533-4134A0F97CEA} &lt;/string&gt;
   &lt;string&gt;IApplicationViewCollection,{2C08ADF0-A386-4B35-9250-0FE183476FCC} &lt;/string&gt;
   &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
@@ -33,8 +33,8 @@
 &lt;/ArrayOfString&gt;</Value>
     </Setting>
     <Setting Name="v_22000" Type="System.Collections.Specialized.StringCollection" Scope="Application">
-      <Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
-&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
+      <Value Profile="(Default)">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;
+&lt;ArrayOfString xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   &lt;string&gt;IApplicationView,{372e1d3b-38d3-42e4-a15b-8ab2b178f513} &lt;/string&gt;
   &lt;string&gt;IApplicationViewCollection,{1841c6d7-4f9d-42c0-af41-8747538f10e5} &lt;/string&gt;
   &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9} &lt;/string&gt;
@@ -47,5 +47,9 @@
   &lt;string&gt;IVirtualDesktopPinnedApps,{4ce81583-1e4c-4632-a621-07a53543148f} &lt;/string&gt;
 &lt;/ArrayOfString&gt;</Value>
     </Setting>
+    <Setting Name="v_22621" Type="System.Collections.Specialized.StringCollection" Scope="Application">
+      <Value Profile="(Default)">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt; &lt;ArrayOfString xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;&gt;    &lt;string&gt;IApplicationView,{372E1D3B-38D3-42E4-A15B-8AB2B178F513}&lt;/string&gt;    &lt;string&gt;IApplicationViewCollection,{1841C6D7-4F9D-42C0-AF41-8747538F10E5}&lt;/string&gt;  &lt;string&gt;IObjectArray,{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}&lt;/string&gt;    &lt;string&gt;IServiceProvider,{6D5140C1-7436-11CE-8034-00AA006009FA}&lt;/string&gt;    &lt;string&gt;IVirtualDesktop,{536D3495-B208-4CC9-AE26-DE8111275BF8}&lt;/string&gt;     &lt;string&gt;IVirtualDesktopManager,{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopManagerInternal,{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopNotification,{cd403e52-deed-4c13-b437-b98380f2b1e8}&lt;/string&gt;     &lt;string&gt;IVirtualDesktopNotificationService,{0cd45e71-d927-4f15-8b0a-8fef525337bf}&lt;/string&gt;  &lt;string&gt;IVirtualDesktopPinnedApps,{4CE81583-1E4C-4632-A621-07A53543148F}&lt;/string&gt; &lt;/ArrayOfString&gt;</Value>
+    </Setting>
   </Settings>
-</SettingsFile>
\ No newline at end of file
+</SettingsFile>
+

Aight the following patch worked for me!

ZhulaiIvan commented 2 years ago

how do you install this patch? Sorry, i don't understand anything.

maciej-makowski commented 2 years ago

Hi @Grabacr07.

I've made a PR with a fix for this issue on newer Windows 11 builds: https://github.com/Grabacr07/VirtualDesktop/pull/79. This may also fix some newer Window 10 installations due to the changes in how COM GUIDs are selected.

Have a look when you get a chance and let me know if you're happy to accept it as is or you'd like some changes.

Dexterously commented 2 years ago

@maciej-makowski,

Thanks a lot! Just downloaded your version and its working 🎉

maxpavlov commented 1 year ago

@maciej-makowski fantastic work. I am still hoping @Grabacr07 will merge this in so I don't have to switch to your fork's code base, however if this isn't coming please consider making more enhancements to your fork :)

renil-joy commented 1 year ago

Thanks a lot @maciej-makowski, I was facing same error and able to run with your fork's code.

maciej-makowski commented 1 year ago

I've reached out to @Grabacr07 when I made this change offering help maintaining this library. He hasn't responded yet. I might get around publishing my fork as a separate NuGet package, since I myself came across the issue via https://github.com/glsorre/amethystwindows/issues/86 and it would be great to have a working official build of AmethystWindows.

Taster-git commented 1 year ago

Hi @Grabacr07.

I've made a PR with a fix for this issue on newer Windows 11 builds: #79. This may also fix some newer Window 10 installations due to the changes in how COM GUIDs are selected.

Have a look when you get a chance and let me know if you're happy to accept it as is or you'd like some changes.

Hi @maciej-makowski I faced same issue, Used your fork code but now facing following issue after using your branch on Win-10 Pro , build # 19045

Please guide to solve or make another commit. Thanks

System.NotImplementedException: 'The method or operation is not implemented.'

Stack Trace

at WindowsDesktop.Interop.IServiceProvider.QueryService(Guid& guidService, Guid& riid)
   at WindowsDesktop.Interop.ComInterfaceAssembly.CreateInstance(Type type, Nullable`1 guidService) in D:\VirtualDesktop\src\VirtualDesktop\Interop\ComInterfaceAssembly.cs:line 60

Line of Code

private static object CreateInstance(Type type, Guid? guidService)
        {
            var shellType = Type.GetTypeFromCLSID(CLSID.ImmersiveShell)
        ?? throw new Exception($"Type of ImmersiveShell ('{CLSID.ImmersiveShell}') is not found.");
            var shell = Activator.CreateInstance(shellType) as IServiceProvider
                ?? throw new Exception("Failed to create an instance of ImmersiveShell.");

                return shell.QueryService(guidService ?? type.GUID, type.GUID);   **//Error at this Line**
        }
maciej-makowski commented 1 year ago

Hi @Taster-git,

That usually means that Microsoft changed the underlying Windows API between versions adding new function or parameter. I don't remember of the top of my head how you can find it, I will try to find some time this weekend to review how what I did few months ago

Taster-git commented 1 year ago

Hi @Taster-git,

That usually means that Microsoft changed the underlying Windows API between versions adding new function or parameter. I don't remember of the top of my head how you can find it, I will try to find some time this weekend to review how what I did few months ago

Thanks for your reply. Ok waiting on daily basis.

Slion commented 1 year ago

Does this mean that @maciej-makowski changes which fixed Windows11 22H2 broke support for older Windows 10 versions? I doubt Microsoft is changing those API on Windows10 these days. Last I looked at the code I recall @Grabacr07 had a clever system to support different variant of those APIs so in theory we should be able to fix it without breaking earlier versions. Shame he has been MIA for almost a year now. If only the process of adding support for new Windows version had been documented.

3dtoall commented 1 year ago

I've reached out to @Grabacr07 when I made this change offering help maintaining this library. He hasn't responded yet. I might get around publishing my fork as a separate NuGet package, since I myself came across the issue via glsorre/amethystwindows#86 and it would be great to have a working official build of AmethystWindows.

Hello @maciej-makowski ! Any news or updates? I think is not working on latest Windows 11 version? Thank you to keep updating this.

maciej-makowski commented 1 year ago

Hi @3dtoall.

I have never heard back from @Grabacr07 on the maintenance. I was toying with the of maintaining a fork of this package a while ago, but after looking a bit more into it, decided against it.

The reason why this package keeps breaking between Windows upgrades is, it depends on an undocumented low-level functions in Windows API. This is also a reason why it's quite difficult to fix and relese, since every time new Windows 10 or 11 version gets released it's a potential breaking change and you have to reverse-enginner the API calls and patch the library. I briefly looked into automating the process, but couldn't work it out and ultimately gave up on the idea.

I think, until VirtualDesktop Windows API stabilises, this will always be a big maintenance burden and unfortunately, I don't have this much time available.

Slion commented 1 year ago

Looks like this guy has it working.

Slion commented 1 year ago

@maciej-makowski I just test your patch and it seems to work fine still on 22621.

Any chance we could document the reverse engineering process? So that next time around someone else could take that burden?

Slion commented 1 year ago

I just published it as Slions.VirtualDesktop for anyone to use. Did minimal testing with it and it seems to be working fine. I'm planning to update that Taskbar Pro app of mine to make use of it.

Slion commented 1 year ago

I've added documentation about finding class IDs for your version of Windows: https://github.com/Slion/VirtualDesktop#windows-version-support

anaisbetts commented 1 year ago

@Slion This is still broken on build 25926.rs_prerelease.230804-1441

Slion commented 1 year ago

Is that insider build? You can follow the instructions above to fetch the IDs. If you give them to me I'll publish them and you can try it out.

anaisbetts commented 1 year ago

@Slion Unfortunately it seems they have removed the registry entries that you referenced, at least in some installs (I've read that whether these IID entries exist depend on when you installed the OS), searching for IApplicationView with "Match whole word" returns zero results

Slion commented 1 year ago

Could you reference your sources? Did you try to search the whole registry? Maybe it's in another path? If that's the case we will need to find another way to get them, somehow.

Slion commented 1 year ago

Looks like this article could be useful to obtain our Ids: https://www.mandiant.com/resources/blog/hunting-com-objects

Would be fantastic if @Grabacr07 and @maciej-makowski would find some time to share their expertise on reverse engineering.

anaisbetts commented 1 year ago

Did you try to search the whole registry? Maybe it's in another path?

I searched the entire registry, there are lots of partial matches but checking "Use Whole Word" => zero matches.

Slion commented 1 year ago

I searched the entire registry, there are lots of partial matches but checking "Use Whole Word" => zero matches.

That's weird, my insider build is currently 25206 and there too I can't find those ids anywhere in the registry. We will have to find another way then.

Slion commented 1 year ago

Looks like the link above is exactly what we need.

You first need to get the list of all CLSID on your system by running the following powershell commands. Mount part of your registry as a drive: New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR Export the CLSID into a text file: Get-ChildItem -Path HKCR:\CLSID -Name | Select -Skip 1 > clsids.txt

Then I ran a modified version of their script which can be resumed after a crash, that looks like that:

$Position  = 1
$StartAt  = 7004
$Filename = "win10-clsid-members.txt"
$inputFilename = "clsids.txt"
ForEach($CLSID in Get-Content $inputFilename) {

      if ($Position -ge $StartAt) {
            Write-Output "$($Position) - $($CLSID)"
            Write-Output "------------------------" | Out-File $Filename -Append
            Write-Output "$($Position)" | Out-File $Filename -Append
            Write-Output "------------------------" | Out-File $Filename -Append
            Write-Output $($CLSID) | Out-File $Filename -Append
            $handle = [activator]::CreateInstance([type]::GetTypeFromCLSID($CLSID))
            $handle | Get-Member | Out-File $Filename -Append
      } else {
            Write-Output "Skip $($Position) - $($StartAt)"
      }

      $Position += 1
}

# Crash on:
# 587
# 845
# 1600
# 2397
# 2872
# 3828
# 4063
# 4517
# 4555
# 5327
# 5699
# 6104
# 6870
# 7003

Sadly no joy I could not find the interfaces we are looking for. I also could not find them in oleview.

Slion commented 1 year ago

Maybe we could locate the DLLs we need and inspect them as suggested here: https://stackoverflow.com/questions/4651869/given-a-com-dll-extract-all-classes-clsid-and-corresponding-interface-name or just using oleview.

Path to oleview.exe, make sure you run it as admin: C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64

Slion commented 1 year ago

So going through VirtualDesktop code they do some pretty savvy stuff. They actually compile a COM DLL at runtime, possibly to help load the actual interfaces implementations. I was wondering if they are in windows.immersiveshell.serviceprovider.dll but that too fails to open in oleview.

sliddington commented 1 year ago

I replied to the email I got for https://github.com/Grabacr07/VirtualDesktop/issues/76#issuecomment-1681653320 thinking it would endup here but seems not....

Yes, I have also found the IDs are removed in some cases too so we may have to fall back to hard coded ids based on build number if they can't be found. I was working on something like that on my fork but not sure I got as far as pushing it up as it still didn't work as I expected.

....

This comment was a previous pull request on this topic. https://github.com/mntone/VirtualDesktop/pull/1#issuecomment-922269079 and describes the process.

twinui.pcshell.dll used to be the dll you are probably looking for.

sliddington commented 1 year ago

Also note the compiled dll is cached and needs to be deleted if you want to pick up changes (unless that has changed). Believe it ends up in %LocalAppData%\grabacr.net\VirtualDesktop\assemblies

May be why my switching versions didn't work as I mention on https://github.com/mntone/VirtualDesktop/pull/1#issuecomment-950427131 ... can't remember if I was aware of that at that point

Slion commented 1 year ago

@sliddington Thanks for the pointers. That looks like extremely valuable information. I know now we need to look at twinui.pcshell.dll using OleViewDotNet. I'll see if I can get the interfaces and IDs we need from my insider build.

Looking at the code I saw the path where it does the ids lookup in the registry and I was wondering if that is still in use. I'm guessing it is not because I recently had to hard code ids for my version of Windows 10 which did have them in the registry.

So IDs are indeed now hard coded per Windows version in the application settings through app.config.

I'll also watch out for caching of that runtime generated DLL. Though that might have been fixed somehow as when I added those new set of IDs the other day I did not have to delete the DLL manually. Though it cloud be I did a clean and rebuild.

Slion commented 1 year ago

Also note the compiled dll is cached and needs to be deleted if you want to pick up changes

I think this explains an issue I'm having with Taskbar. I patched the VirtualDesktop updated it and republished the app but on the Windows 10 I was testing it on it still won't offer virtual desktop features. Most likely the DLL is not being regenerated. I'll have to find a solution for that.

Slion commented 1 year ago

I did try a bunch of stuff with OleViewDotNet and twinui.pcshell.dll but it could not open it. Also I found CLSID_VirtualDesktopDataSourceComponent which lead me to C:\Windows\System32\OneCoreUAPCommonProxyStub.dll but that too can't be opened in OleViewDotNet. No real progress then I'm afraid...

Neither DLLs can be registered using regsvr32.

sliddington commented 1 year ago

Some new information from @mzomparelli on that other thread ... https://github.com/mntone/VirtualDesktop/pull/1#issuecomment-1694723741

Slion commented 1 year ago

@sliddington Thanks for putting me in touch with @mzomparelli as he did come up with a proper reverse engineering of the latest Windows changes. All the good stuff now available from my fork.

sliddington commented 9 months ago

@sliddington Thanks for putting me in touch with @mzomparelli as he did come up with a proper reverse engineering of the latest Windows changes. All the good stuff now available from my fork.

@Slion And thank you for putting in the work to sort this out. I finally had to fix my app after getting a new work computer with Win 11 and it worked without any issues on both 10 and 11.

FYI, it doesn't work if you build your app as a .NET "single file application" because if fails to read the sources for the assembly compilation.