Giter VIP home page Giter VIP logo

sharpshell's Introduction

SharpShell

Build status codecov NuGet GuardRails badge

SharpShell makes it easy to create Windows Shell Extensions using the .NET Framework.

If you find this project useful, please consider Sponsoring!

Installation

Install SharpShell by searching for 'SharpShell' in the NuGet package manager, or using the Package Manager Console:

PM > Install-Package SharpShell

The latest official packages are listed below:

Component Package
SharpShell SharpShell NuGet Package
SharpShellTools SharpShellTools Nuget Package
ServerRegistrationManager ServerRegistrationManager NuGet Package

User Guide

All documentation is being moved to docs.

Some of the most useful guides are:

Supported Shell Extensions

The following extensions are supported by SharpShell.

Shell Context Menus

Shell Context Menus allow the context menus used in Windows Explorer to be customised.

Shell Context Menu Screenshot

Step by Step Tutorial on the CodeProject.

Icon Handlers

Shell Icon Handlers are DLLs that are registered in the system to customise the appearance of icons.

Shell Icon Handler Screenshot

Step by Step Tutorial on the CodeProject.

Info Tip Handlers

Shell Info Tip Handlers are DLLs that are registered in the system to customise tooltips for items in the shell.

Shell Info Tip Handler Screenshot

Step by Step Tutorial on the CodeProject.

Drop Handlers

Shell Drop Handlers are DLLs that are registered in the system to extend the drag and drop functionality in the Shell.

Shell Drop Handler Screenshot

Step by Step Tutorial on the CodeProject.

Preview Handlers

Shell PreviewHandlers are dlls that can be registered in the system to allow you to create visually rich previews for items that are displayed directly in Windows Explorer.

Shell Preview Handler Screenshot

Step by Step Tutorial on the CodeProject.

Icon Overlay Handlers

Shell Icon Overlay Handlers can be really useful. They let you display an icon overlay over shell objects to provide extra information. Programs like Dropbox use these overlays to show whether files are synchronised or not.

Shell Icon Overlay Handler Screenshot

Step by Step Tutorial on the CodeProject.

Thumbnail Handlers

Shell Thumbnail Handlers (or as they're sometimes known, Shell Thumbnail Providers) are COM servers that you can write to customise the appearance of the thumbnail icons in the Windows Shell.

Shell Thumbnail Handler Screenshot

Step by Step Tutorial on the CodeProject.

Property Sheet Extensions

These are extensions that add extra pages to the property sheets shown for shell items such as files, network shares, folders and so on.

Shell Thumbnail Handler Screenshot

Documentation.

Desk Band Extensions

These are extensions which add custom functionality to the Windows Desktop or Task Bar.

Shell Desk Band Screenshot

Documentation

Developer Guide

The repository made up the following components:

Component Description
docs/ Project Documentation
SharpShell/ The core SharpShell assemblies.
SharpShellInstallerSample/ An example of an installer for a SharpShell extension.
SharpShellNativeBridge/ Interface to Win32 code needed for property sheets.
Tests/ Regression test scripts and data.

Most developers will only need to work with the code in the SharpShell folder.

SharpShell is currently developed in Visual Studio 2017, and can be built using the Community Edition.

In order to maximize compatibility, we do not use the latest version of each SDK. The following components are needed:

  • .NET Core runtime
  • Microsoft Visual Studio 2017 Installer Projects
  • Chocolatey (choco)

Building & Testing

As long as the correct components have be installed for Visual Studio, you should be able to just open the main ./SharpShell/SharpShell.sln solution to build, test and run any of the code or samples.

To build using Powershell (which is what is done in the CI/CD process), first allow Powershell to execute scripts and then install Chololatey:

Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

Now the following scripts to run the processes:

Script Notes
config.ps1 Ensure your machine can run builds by installing necessary components such as nunit. Should only need to be run once.
build.ps1 Build all solutions. Ensures that we build both 32/64 bit versions of native components.
test.ps1 Run all tests, including those in samples.
coverage.ps1 Create a coverage report for the main SharpShell project (samples are not included). Reports are written to ./artifacts/coverage

These scripts will generate various artifacts which may be useful to review:

artifacts\
  \build
    \SharpShell           # The SharpShell assembly.
  \tests                  # NUnit Test Reportsd
  \coverage               # Coverage Reports

Only assemblies and binaries which need to be copied into other projects are added to the artifacts/build folder. This makes chaining more complex dependencies manageable. The solution is fairly standard, but be aware that:

  1. SharpShell contains the SharpShellNativeBridge binaries. To update them, build the SharpShellNativeBridge solution from source and embed the new binaries.
  2. The SharpShell assembly is copied to artifacts/build/SharpShell folder after a successful build.
  3. The SharpShell assembly is embedded in the ServerRegistrationManager binary. The assembly is copied from artifacts/build/SharpShell prior to the server registration manager build.

All of the above steps are automated, and will run whether a build is trigger from Visual Studio, the build.ps1 script or msbuild.

Enabling Logging

A detailed guide explaining how to configure and use logging for SharpShell is at:

./docs/logging/logging.md

You can also use the SharpShell-Easy-Log tool to quickly enable/disable logging options and view the logs realtime:

SharpShell Easy Log

The tool is available at: github.com/ElektroStudios/SharpShell-Easy-Log

CI/CD

CI/CD is currently handled by AppVeyor. AppVeyor will:

  1. Build the project
  2. Run the tests
  3. Create the core SharpShell NuGet Package
  4. Publish the package to nuget.org if a version tag is pushed
  5. Create a GitHub release with the package if a version tag is pushed

Creating a Release

To create a release:

  1. Update the version number in SharedAssemblyInfo.cs
  2. Update the CHANGELOG.md
  3. Create a new version tag, then push

AppVeyor will build and publish a new NuGet package and as long as a new semver tag is pushed.

Compatibility

The goal is to maximize compatibility for platforms which are supported. For platforms which are no longer in support SharpShell may work, but is not tested.

Note: At the moment compatibility across platforms is being verified, this section of the documentation will be updated soon.

๐ŸŸข - Fully Supported; tested and verified as part of the build process ๐ŸŸ  - Partly Supported; potentially will work, but no longer formally supported or tested ๐Ÿ”ด - Not Supported; confirmed that this will not work, unless the code is modified

Component Compatibility
Windows
Windows 11 ๐ŸŸข Fully Supported
Windows 10 ๐ŸŸข Fully Supported
Windows 8.1 ๐ŸŸ  Partly Supported
Windows 8 ๐ŸŸ  Partly Supported
Windows 7 ๐ŸŸ  Partly Supported
Visual Studio
Visual Studio 2022 ๐ŸŸข Fully Supported
Visual Studio 2019 ๐ŸŸข Fully Supported
Visual Studio 2017 ๐ŸŸ  Partly Supported
Visual Studio 2015 ๐ŸŸ  Partly Supported
msbuild
msbuild 17.3 ๐ŸŸข Fully Supported
msbuild 16.11 ๐ŸŸข Fully Supported
msbuild 15.9 ๐ŸŸ  Partly Supported

Documentation

Documentation is still work in progress, and any contributions would be most welcome!

Contributor Guide

The project is maintained by the following group:

User Role
dwmkerr Project creator, maintainer.
Countryen Project maintainer.

We have a Code of Conduct aimed at keeping the community welcoming and inclusive.

Testimonials

If you've used SharpShell and would like to add a testimonial, just send me a message!

CmisSync, our Dropbox-like client for Enterprise Content Management servers, just switched to SharpShell, and we are extremely pleased with this library. Our previous custom-built Windows Explorer integration was buggy, unreliable and hard to maintain, and SharpShell is really rock-solid in comparison. The best part: It only took 2 days to integrate SharpShell into our software, testing and installer included. Thanks SharpShell!

Nicolas Raoul - CmisSync.com

Projects that use SharpShell

Send me a message to add a project to this list:

Thanks

Many thanks to JetBrains for providing an Open Source License for their products!

JetBrains

License

SharpShell is licensed under the MIT License - the details are at LICENSE.md

sharpshell's People

Contributors

apuchitnis avatar azhe403 avatar chaoses-ib avatar darkcreekway avatar dgtvan avatar dramacydal avatar dwmkerr avatar elektrostudios avatar g-pearson avatar gpetrou avatar guardrails[bot] avatar havendv avatar hmemcpy avatar king2500 avatar kkguo avatar ln avatar nicolas-raoul avatar otociulis avatar overengineered avatar petsuter avatar repiteo avatar sagaru avatar timsol avatar uranvester avatar vasilyfomin avatar zakamurite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpshell's Issues

Restart windows required

I am using the code below to create a SharpDropHandler and have built a custom installer per your article. After I build and install the code below it appears I need to restart windows 8.1 for any updates in the code to be reflected. Same issue with the test tool. Anyone got any ideas?

using SharpShell.SharpDropHandler;
using System;
using System.IO;
using System.Windows.Forms;
using System.Linq;
using System.Runtime.InteropServices;
using SharpShell.Attributes;
[ComVisible(true)]
[COMServerAssociation(AssociationType.ClassOfExtension, new string[] { ".xls", ".xlsx", ".xlsb", ".xlsm"})]
public class ExcelDropHandler : SharpDropHandler
{

/// <summary>
/// Checks what operations are available for dragging onto the target with the drag files.
/// </summary>
/// <param name="dragEventArgs">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
protected override void DragEnter(DragEventArgs dragEventArgs)
{  
    string[] validextensions = new string[] { ".xls", ".xlsx", ".xlsb", ".xlsm"};
    dragEventArgs.Effect =
       DragItems.All(di =>  validextensions.Contains(Path.GetExtension(di)))
            ? DragDropEffects.Link : DragDropEffects.None;

}

///// <summary>
///// Performs the drop.
///// </summary>
///// <param name="dragEventArgs">The <see cref="System.Windows.Forms.DragEventArgs"/> instance containing the event data.</param>
protected override void Drop(DragEventArgs dragEventArgs)
{   
    string[] files = (string[])dragEventArgs.Data.GetData(DataFormats.FileDrop);
    MessageBox.Show(String.Format("Comparing {0} to {1}",  SelectedItemPath, files[0]));
}

}

Non ANSI characters broken in context menu

Originally: https://sharpshell.codeplex.com/workitem/1399

Working with a SharpContextMenu, I selected a file with Russian characters in the path. Those characters were not marshalled correctly and appeared as question marks.

I was able to fix this by changing Shell32.DragQueryFile(), adding

[MarshalAs(UnmanagedType.LPWStr)] to lpszFile. I.e.:
    [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
    public static extern uint DragQueryFile(IntPtr hDrop, uint iFile, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszFile, uint cch);

Doesnt work

it only works on test, but when im installing server doesnt work

Possbile Bug with Preview Handler

@dwmkerr Investigate:

Hi, you can download the zip containing the project from here:

http://sanskrityantra.org/MDPreview.zip

I tried to install the preview handler on Windows 8.1 and Windows 7, but it does not work.
It works in ServerManager if I load the server, install it and register it, and then choose menu Test Server in Server Shell.
To test it, you can try to get the preview of the .md file in the bin directory.

Thanks in advance

Support Shell Debugger

The Shell Debugger is being developed in d/ShellNamespaceExtension:

https://github.com/dwmkerr/sharpshell/tree/d/SharpNamespaceExtension/SharpShell/Tools/ServerManager/ShellDebugger

Currently when the debugger window is opened, an exception is thrown. The root cause seems to be that this line:

https://github.com/dwmkerr/sharpshell/blob/d/SharpNamespaceExtension/SharpShell/Tools/ServerManager/ShellDebugger/ShellDebuggerForm.cs#L182

Doesn't create a window handle. If we can have the debug window working, we can debug the namespace extensions properly,

DeskBands: Enforce Display Name

If a SharpShell DeskBand has no displayname attribute, it won't register (as Windows doesn't know what to cal it in the menu) we must at least validate that this attribute is present when performing registration or validation.

Add Resharper Thanks

Need to add the resharper/jetbrains logo to the readme and thank them for the license for the next release.

Server Manager Doesn't Remove Bad Servers

If you attempt to load a bad file for a sharpshell server, the server manager seems to add it to the list of servers and attempts to load it on each startup, servers that fail to load on startup should be removed from the list

CreateMenu is not always called.

Is it possible to force CreateMenu to be called after every CanShowMenu call? I need to customize the context menu for each file selected but CreateMenu is only being called after the first file selected.

SharpShellTools 2.1 is mispackaged

Apparently the nuget package for SharpShellTools 2.1 is referencing the old version of sharpshell as a dependency, this needs to be fixed

Support Advanced Registration Options for SNEs

Shell namespace extensions have more options than are exposed for registration, e.g:

  • WantsFORPARSING
  • HideAsDelete
  • HideAsDeletePerUser
  • QueryForOverlay
  • support custom verbs with a 'Shell' subkey.
  • support custom shortcut menu handler with ShellEx.
  • tie in support for a property sheet handler.

Win 8.1/64 IconHandler

Hi,

how can I debug your native bridge and SharpShell? I have problem with IconHandler, and after installing(x64) and registering(x64) your sample explorer sometimes works and sometime crashes. But test in your ServerManager is OK. Or can you look at it and fix it?

Thank you
Peter

Can't use * class for every type of file for SharpContextMenu

When you try to do the following:

[COMServerAssociation(AssociationType.ClassOfExtension, "*")]
public class ShellExtension : SharpContextMenu

RegAsm will fail and complain that The specified path is invalid. After digging through the code really quickly, not having much experience with shell extensions yet, it seems that it's trying to get the default value of HKCL\*, which is null in all cases, where as every other class such as .txt actually have a correct default value: txtfile for example.

Is it not possible to implement a handler for *? Is there a workaround for this, or will there be a fix?

Thanks for the great library, by the way!

[ContextMenu] CanShowMenu implemented for each submenu?

First of all, huge kudos for creating such a great project!

Here's my concern.
CanShowMenu() is called on every rightclick on a file or directory, and since I'm doing some more advanced inter-process communication in the logic, it might take some time to get the reply, but it would be terrible to hog every right click and make the user wait for the response from my app.
So I thought I can just put it all in a submenu which would simply always be shown, and only when the user opens it it would run the IPC to ask whether to put the elements inside. I think that's a pretty common use-case.
So I tried to put the logic into an event of the item, like so:
mainItem.DropDownOpening += (s, a) => { Log("Opened"); };
But the event never fires. It seems it's not translated into the underlying native User32 event (if such a thing even exists, I'm no specialist in that).

Is there any way to make each submenu added to the ContextMenu implement it's own CanShowMenu logic? Supporting the events would be even better, but a working workaround might make sense too.

I've researched a bit, but extern libs aren't my piece of cake, so I don't know if this might be of any help:
http://www.codeproject.com/KB/edit/cmenuedit.aspx?msg=2774005#xx2774005xx

Many thanks!

Investigate FolderPath issue

Dear Dave,
I encountered a strange behaviour which took me a while to find out: When testing with ContextMenus and the TestServer from ServerManager.exe both variables FolderPath and SelectedItemPaths work fine.
But when testing without TestServer but InstallServer and RegisterServer with ServerManager.exe instead, the variable FolderPath is always null. I had to set a variable by myself with
string FolderPath = Path.GetDirectoryName(SelectedItemPaths.First()). I am using SharpShellTools 2.1.0.1 and SharpShell 2.1 from NuGet.
Thank you for your great work,
Klaus

Shell Preview Handler Flickering

Shawn Rubie has discovered some potential issues with the icon preview handler. Original post:

http://www.codeproject.com/Articles/533948/NET-Shell-Extensions-Shell-Preview-Handlers?msg=4922298#xx4922298xx

Hi again,

When I got the preview control working, I had severe flickering issues when the explorer window (and inside it, the preview control) was being resized. Your base control uses WS_EX_COMPOSITED, which I read is supposed to help with flickering issues in XP, but apparently in Vista and Win7 that flag is ignored? I did manage to find a way to eliminate the flickering though:

On a resize of the explorer window, IPreviewHandler.SetRect is called, which calls UpdateHost(), which calls SetParent, sets the Bounds property, and sets Visible true for both previewHostHandle and previewHandlerControl. I'm guessing that calling SetParent causes erasing and redrawing, because if instead it only updates the Bounds when SetRect is called (really, only SetParent and Visible needs to be set once when IPreviewHandler.SetWindow is called, right?), the flickering issues disappeared for me in Win7.

To summarize, I changed SetRect to call this UpdateBounds() method below, in place of the existing UpdateHost() method, and the flickering I was seeing went away.

      /// <summary>
      /// Updates the size of the controls
      /// </summary>
      private void UpdateBounds()
      {
            OnPreviewHostThread(
                  () =>
                  {
                        //   Set the bounds of the host and control
                        previewHandlerHost.Bounds = new Rectangle(previewArea.left, previewArea.top, previewArea.Width(), previewArea.Height());
                        previewHandlerControl.Bounds = new Rectangle(previewArea.left, previewArea.top, previewArea.Width(), previewArea.Height());
                  }
            );
      }

Again, thanks for your work on the library, and your responses to my earlier questions.

Shawn

Support Server Validation

The server manager can validate a server, e.g. checking that it has the correct attributes and so on.

Logs in EventLog

Hi!

First of all thanks for this great library!

And now to business =)
Is it possible to hide logs in EventLog? It looks like, that message in EventLog are generated for every "CanShowOverlay" call.

I have built my extension (OverlayIcon) in Release Mode and installed it using srm.exe.
I'm using SharpShell 2.1.

I have also tried to used next command, but, it seems to me, it's not related to my problem.

SharpShell.Diagnostics.Logging.EnableLogging(false);

Thanks in advance!

Namespace shell extensions support?

Hi!

I just found this library today after an exhaustive search about any information about how to add items to the navigation pane of Windows Explorer. After a while I realized that those are called Namespace extensions.
I'm basically interested to add a "top-level" item to the navigation pane (and the open/save file dialog), just like the Homegroup item:

image

So that clicking on it can interact and display the content of my choosing.

Some reading led me to understand I need to implement a bunch of things, mainly IShellFolder, and I was wondering whether SharpShell had any support for this already? If not, would you be interested in a pull request, in case I could hack something myself? :)

Thanks!

Namespace Extensions: Exception for MyComputer/CurrentUser

When I change the GitHub namespace extension to have MyCoumpter as the virtual junction point but for current user, an exception is thrown trying to open the correct key to create the registry entries as children of.

This is possibly because there are no per-user namespace extensions already installed, so part of the path to the required location might be missing - or it might be that some junction points are not supported for the current user. If that's the case, we need to throw an exception when attempting to register with such a configuration, informing the caller that it's not supported. If it's just that path elements are missing, we can create them as needed (and if that's the case, this bug will crop up for others when installing on vanilla machines).

Context Menu: Doesn't work for shortcuts

Hello!

It seems that it doesn't work completely for shortcuts, it works perfectly with files and directories, but not with shortcuts.
It adds new items to context menu well, but when I click on some new added item it doesn't invoke command that should be performed.
I've made small investigation and noticed one thing (I hope, it will help you a little bit) :
when I click on new added item in the context menu in the function 'IContextMenu.InvokeCommand(IntPtr pici)'(SharpContextMenu.cs file) variable 'iciex' in fields 'verb' and 'verbW' has too big numbers like 236255072 or 286797496 and then it can not match this click to the appropriate command.

Thanks in advance.

Tidy Up Registry Code

We can tidy up the registry code by creating extension methods that do the null checks and throw exceptions.

Invalid SelectedItem Count with > 16 items

See: http://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus?msg=4710563#xx4710563xx

Hey,

when I'm right-clicking on more than 16 selected files and/or directories for the first time, my context menu handler don't show up on each file/directory as I'd expect. I found out that this happens because at the very beginning the selectedItem count is somehow set to 16, although I have selected a lot more than 16 files and/or directories. But when I click on the handler of one of the file/directory which shows the menu, the selectedItem count is set to the real number of elements I have selected.

Do you have any suggestion why this happens or what I could do to avoid this behaviour?

Thanks!!

Fix srm.exe DLL dependencies loading

Hello,
I had to tune srm.exe (v 2.1) for the following scenario :
-I have an assembly A.dll (made with C#) that contains my ISharpShellServer exports
-A.dll has a dependency : B.dll (made with C++/CLI)
-A.dll and B.dll are in the same folder
-when trying to use "srm.exe install A.dll -codebase", it fails, claiming that "B.dll" cannot be found

Please note that regasm.exe A.dll /register /codebase does not fail and works very well in that case.

My solution :
ServerRegistrationManager.HandleEmbeddedReference is already used to install a resolve handler
The resolve handler should be smarter. Actually, it is only used to load embedded resources. But it should work for external dependencies as well.
When it is called for B.dll, It should try to load it from the folder of A.dll.

It works, I have done it.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.