@@ -23,7 +23,7 @@ public class Registrar
2323 protected readonly string SyncRootId ;
2424 protected readonly string UserFileSystemRootPath ;
2525 protected readonly ILog Log ;
26- private readonly IEnumerable < ( string Name , Guid Guid ) > shellExtensionHandlers ;
26+ private readonly IEnumerable < ( string Name , Guid Guid , bool AlwaysRegister ) > shellExtensionHandlers ;
2727
2828 /// <summary>
2929 /// Creates instance of this class.
@@ -37,7 +37,7 @@ public class Registrar
3737 /// List of shell extension handlers. Use it only for applications without application or package identity.
3838 /// For applications with identity this list is ignored.
3939 /// </param>
40- public Registrar ( string syncRootId , string userFileSystemRootPath , ILog log , IEnumerable < ( string Name , Guid Guid ) > shellExtensionHandlers = null )
40+ public Registrar ( string syncRootId , string userFileSystemRootPath , ILog log , IEnumerable < ( string Name , Guid Guid , bool AlwaysRegister ) > shellExtensionHandlers = null )
4141 {
4242 this . SyncRootId = syncRootId ;
4343 this . UserFileSystemRootPath = userFileSystemRootPath ;
@@ -71,16 +71,8 @@ public async Task RegisterSyncRootAsync(string displayName, string iconPath, str
7171
7272 if ( shellExtensionHandlers != null )
7373 {
74- // Register thumbnails handler, custom states handler, etc,
75- // but only if this app has no identity. Otherwise manifest will do this automatically.
76- if ( ! PackageRegistrar . IsRunningWithIdentity ( ) )
77- {
78- RegisterShellExtensions ( shellExtensionsComServerExePath ) ;
79- }
80- //else
81- //{
82- // Log.Debug("\nThis app has identity. Shell extensions list is ignored. Shell extensions must be installed via sparse package manifest or app packaged app manifest.");
83- //}
74+ // Register thumbnails handler, custom states handler, etc.
75+ RegisterShellExtensions ( shellExtensionsComServerExePath ) ;
8476 }
8577 }
8678
@@ -166,13 +158,18 @@ public virtual async Task UnregisterAsync(EngineWindows engine, bool fullUnregis
166158 /// </remarks>
167159 private void RegisterShellExtensions ( string shellExtensionsComServerExePath = null )
168160 {
161+ bool isRunningWithIdentity = PackageRegistrar . IsRunningWithIdentity ( ) ;
169162 foreach ( var handler in shellExtensionHandlers )
170163 {
171164 if ( ! ShellExtensionRegistrar . IsHandlerRegistered ( handler . Guid ) )
172165 {
173- Log . Info ( $ "\n Registering shell extension { handler . Name } with CLSID { handler . Guid : B} ...\n ") ;
174-
175- ShellExtensionRegistrar . RegisterHandler ( SyncRootId , handler . Name , handler . Guid , shellExtensionsComServerExePath ) ;
166+ // Register handlers only if this app has no identity. Otherwise manifest will do this automatically.
167+ // Unlike other handlers, CopyHook requires registration regardless of identity.
168+ if ( ! isRunningWithIdentity || handler . AlwaysRegister )
169+ {
170+ Log . Info ( $ "\n Registering shell extension { handler . Name } with CLSID { handler . Guid : B} ...\n ") ;
171+ ShellExtensionRegistrar . RegisterHandler ( SyncRootId , handler . Name , handler . Guid , shellExtensionsComServerExePath ) ;
172+ }
176173 }
177174 }
178175 }
0 commit comments