SciTE Context Menu Extension


Windows SciTE Context Menu (WSciTEcm) is a context menu handler that gives the ability, on Windows, to quickly open selected files with the source code editor SciTE in Windows Explorer.

Windows SciTE Context Menu in Action

Summary

Installation

For a friendly installation, I recommend to use the SciTE setup provided by Bruce Dodson. This Windows installer facilitates the deployment of a custom built version of SciTE and includes additional helpers such as the Context Menu Extension. Check the choice Register shell extension during the installation process.

For a manual installation, read the section Manual Installation below.

Manual Installation

  1. Copy wscitecm.dll in the SciTE directory. Refer to the section Unload the dll below if you have the error: Access is denied.
  2. In the SciTE directory installation, type the command: regsvr32 wscitecm.dll. This registers the DLL. A new entry Edit with SciTE is available in the menu displayed when you right-click on selected files in Windows Explorer.

Installation on Vista 64-bit

The package containing the binaries includes wscitecm.dll and wscitecm64.dll. On Vista 64-bit, use wscitecm64.dll.

Dependencies

Versions 1.3.0 and 1.4.0 were built with Visual Studio 2005. Therefore, you may need to download and install the corresponding redistributable package. Here are the Microsoft URLs for the redistributable packages:

Uninstallation

  • Due to the introduction of a different GUID in version 1.4.0, is it important to uninstall any version up to 1.3.0 prior to installing any 1.4.0 and above version. If you forget the uninstallation step you may end up with two entries in the context menu. Nevertheless you can still solve this issue by editing the registry or simply by using wscitecm-remove.reg as explained below.
  • To uninstall a 1.2 version and above:
    • In the SciTE directory installation, type the command: regsvr32 /u wscitecm.dll.
  • To uninstall a version prior to 1.2:
    • Double-click on the file wscitecm-remove.reg (included in the source and binary packages). This will clean-up the old registry keys. This script was provided by Bruce Dodson.

Unload the DLL

If you try to delete or override the wscitecm.dll and you get the error Access is denied, it means that the library is already loaded. There are several options to workaround this issue:

  • Solution 1:
    • Close all the Windows Explorer instances open on your desktop and copy wsctecm.dll using the command line (Example: copy wscitecm.dll scite_directory).
  • Solution 2:
    • Reboot the computer and delete or override wscitecm.dll (Example: copy wscitecm.dll scite_directory) before starting Windows Explorer and before using the context menu.
  • Solution 3:
    • Open a command line window
    • Press Ctrl+Alt+Del to display the Windows Task Manager, display the Process tab and kill the explorer.exe process.
    • If the exlorer did not restart automatically, start it manually from the command line window: C:/>explorer.
    • Delete or override wscitecm.dll before using the context menu (Example: copy wscitecm.dll scite_directory).

Build

Until version 1.2.1, wscitecm was built with Visual C++ 6.0. Versions 1.3.0 and 1.4.0 were built with Visual Studio 2005. A Makefile is provided with the sources: in the source directory, type nmake. Ensure that all the environment variables and paths are set correctly. To do so, use the command file VCVARS32.BAT available in the bin directory of Visual C++ installation.

File Releases

Release Notes

  • Version 1.4.0 (12/06/2008):
    • Fixed an issue with the manifest file introduced  with Visual Studio 2005 compilaton
    • Created a new GUID to avoid conflict with Notepad++ reusing this wscitecm code with the same GUID.
  • Version 1.3.0 (05/28/2008):
    • Paul Roukema implemented fixes to provide support for Windows Vista 64-bit
    • Built with Visual Studio 2005
    • Fixed warnings related to string functions
  • Version 1.2.1 (01/21/2003):
    • Released under the MIT License and packaged with the source code.
  • Version 1.2:
    • Registration and unregistration of the Shell Extension embedded in the DLL (wscitecm.dll).
    • SciTE icon displayed in the context menu.
  • Version 1.x:
    • Initial version.

Derived Work

To address personal needs, Angelo Mandato has been maintaining a forked version of WSciTEcm since 01/27/2004.

Legal

Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

,

  1. #1 by Hajo Schlingensief - January 4th, 2008 at 16:18

    Hello André,

    thank you very mutch for the “SciTE Context Menu Extension”.
    Very great Code!
    I have modify your project to use it for a upcoming version
    of my program Drag’n'Crypt ULTRA (i will give you full credits for your work).
    I hope this is OK for you.

    With best Regards

    Hajo Schlingensief

  2. #2 by André Burgaud - January 4th, 2008 at 23:02

    Hajo,
    You are welcome! This code is available under the MIT license, so there should not be any problem. I’m glad it can be useful. Be aware that the current version is not working properly on Vista 64bit. This issue was reported to me a while ago by Don Ho, the lead developer of Notepad++. I started to work on a fix, but got distracted by other priorities and it is still pending… Let me know if you face the same issue. Thanks. – André -

  3. #3 by Abel - February 26th, 2008 at 19:30

    Andre,
    I saw your DLL through looking at SciTE. If I were to use your code for my own application for a context handler would you be able to show what parts of the code I need to modify?

    Abel

  4. #4 by André Burgaud - February 27th, 2008 at 07:33

    Hi Abel,
    Here is a brief summary of changes that could be done in order to fit a different application:

    • Create a unique identifier to replace the one at the beginning of wscitecm.h
    • Modify the different strings that are specific to SciTE including the registy keys in wscitecm.cpp
    • Modify the logic performed to handle the main executable (SciTE.exe) in wscitecm.cpp
    • Use a different icon

    - André -

  5. #5 by Paul - May 3rd, 2008 at 15:49

    I find this extension to be indispensable, but have recently moved to a 64-bit vista environment. I’ve managed to get the extension to compile in 64-bit mode using the compilers included in the windows SDK. The makefile needs some tweaking and variable needs to be changed in type, other than that, smooth sailing.

  6. #6 by André Burgaud - May 4th, 2008 at 00:20

    Hi Paul,
    Would you mind to share your modifications? I never had a chance to address this issue and it would be nice if everyone using this feature on Vista 64-bit could also benefit from some “smooth sailing” ;-) – André -

  7. #7 by Kun - May 11th, 2008 at 15:25

    I think I just run regsvr32 as administrator under vista x64, and then the context menu works after reboot.

  8. #8 by Naveed - May 16th, 2008 at 09:44

    Here’s the x64 version if you need it: http://timebend.com/WSciteCMx64.dll

  9. #9 by André Burgaud - May 26th, 2008 at 21:34

    Paul Roukema shared the source code fixing issues on Vista 64-bit. Those fixes have been merged into wscitecm version 1.3.0 and available for download in this article. Thank you Paul for this contribution. – André -

  10. #10 by Jorr - June 16th, 2008 at 23:53

    Hey André,

    I have the most curios problem with the Scite context menu handler. I installed Scite via Dodson’s package (i believe it’s the same) and for a while had the menu item alright. However, after installing the Notepad++ application it seemed to replace Scite in the context menu. I had an extensive research on this last night and after trying to mimic every key I found about Notepad++ in the registry, I still got nothing. After seeing the source of your DLL, I believe the reason for this is that SOMEHOW Notepad++ uses the same GUID as CLSID in the registry. I always thought the chances for that are practically zero, but here we are. Either they were generated the same independantly which seems almost impossible or maybe the Notepad++ registration dll has used this one as a model, I don’t know.

    Anyway,

    i guess that by using my new GUID in the .h file and rebuilding, I’m gonna do the trick. But thought you should know and maybe contact the notepad++ team or change the guid yourself in your DLL, as I am pretty sure everyone having both programs will have this problem, bearing in mind that uninstalling Notepad++ won’t help unless I re-register wscitecm.dll.

    Of course there are other options to put yourself in the context menu via registry only (the way I discovered EditPad to use, create a key in HKEY_CURRENT_USER\Software\Classes\*\shell) so I could have used that to restore my menu item, but I just wanted to understand the problem.

  11. #11 by Jorr - June 16th, 2008 at 23:55

    After a reread, I might clear some confusion by pointing out that by “my new GUID” I mean the GUID I generated anew and put as CLSID in the registry trying to mimic Notepad++’s own that apparently replaced the original SciTE one.

    I had written this, but apparently deleted this particular sentence somehow before posting..

  12. #12 by André Burgaud - June 17th, 2008 at 07:20

    Hi Jorr,

    Thanks for your comments and for sharing your experience. Sorry that you encountered this problem. This is indeed a known issue that I recently brought to the attention of Don Ho, the lead developer of Notepad++. Notepad++ context menu is based on wscitecm source code, hence this issue. To limit impacts on SciTE users and prevent clashes with Notepad++, I will shortly produce a version of wscitecm with a new unique identifier. – André -

  13. #13 by Jorr - June 17th, 2008 at 09:44

    Thanks, Andre

    I’ll be waiting for your patch since apparently I lack some important know-how about DLL registering. I tried to rebuild your source, but I can’t register it due to missing dependancy. I suspect it is due to the lack of the vc2005 redist, but that doesnt explain why it worked the first time when i installed it (via the kit installer)

  14. #14 by Abel - July 6th, 2008 at 22:01

    Sorry to bother you again, but now that I have downloaded the latest version built with VS2005 what would i need to change to use it for my own app. I definitely dont want to compile and make it conflict with any existing DLLs.

    Abel

  15. #15 by André Burgaud - July 8th, 2008 at 21:45

    Hi Abel,

    To avoid any conflict, you need only to worry about generating a new unique identifier for your application.

    The GUID or UUID can be generated with tools such as Microsoft guidgen. You may also find online solutions like Universally Unique Identifiers (UUIDs).

    Libraries are also available for different platforms and languages. As an example, with .NET and IronPython it gives something like:

    >>> import System
    >>> System.Guid.NewGuid().ToString()
    '728ecfd2-aba8-415f-a8ed-0286fee2d70f'
    >>>
    

    In wscitecm source code, the GUID is declated at the beginning of wscitecm.h.

    - André -

  16. #16 by Jason Black - September 22nd, 2008 at 18:06

    I’ve been trying to use the x64 extension with Vista Business (x64) SP1 to no avail. I’ve installed the VC++ 2005 Redistributal (x64) and even tried the 2008 Redistrib. (x64) to see if that would help. I’m utilizing the wscitecm64.dll file. Everytime I attempt register the .dll I’m receiving a “side-by-side configuration” error. Event log shows “Activation context generation failed for “C:\Program Files (x86)\SciTE\wscitecm64.dll”. Dependent Assembly Microsoft.VC80.DebugCRT,processorArchitecture=”amd64″,publicKeyToken=”1fc8b3b9a1e18e3b”,type=”win32″,version=”8.0.50727.762″ could not be found. Please use sxstrace.exe for detailed diagnosis.”
    From here I’m lost, and not finding any other information about this problem. Maybe I’m missing something. I just can’t think of what it could be, though.

  17. #17 by André Burgaud - September 22nd, 2008 at 21:31

    Hi Jason,

    This is a bug :-(
    There was a problem with the manifest file introduced with Visual Studio 2005. Please try the following 64-bit DLL: http://www.burgaud.com/tmp/wscitecm.dll. This new DLL was successfully tested by a couple of people. I will update this page with the fixed code and binaries.

    Note on 12/06/2008: This issue was addressed in SciTE Context Menu version 1.4.0. The temporary 64-bit DLL was removed.

    -André-

  18. #18 by Torsten Müller - January 1st, 2009 at 08:59

    Hi André,

    first of all thanks for this sample implementation. But here the problem I’m trying to solve since two weeks :-(

    I never see the expected entry “Edit with SciTE” within explorer’s context menu! But it seems to be a general problem because I saw this effect with every sample code I used in the past. Do you have any idea?

    Environment:
    OS: WinXP 64-Bit, SP2
    VS: Visual Studio .NET 2005

    Best regard
    Torsten

  19. #19 by André Burgaud - January 1st, 2009 at 22:31

    Hi Torsten,

    Did you try to install the extension in elevated mode? In the Vista Start Menu, find Command Prompt (cmd.exe), right click and select Run as administrator. In the command prompt window open in elevated mode, change to the directory that contains wscitecm.dll and execute: regsvr32 wscitecm.dll. I’m not sure this will solve this issue, but I would try it if you did not do it yet.

    -André-

  20. #20 by Torsten Müller - January 2nd, 2009 at 06:56

    Hi André,

    thanks for answering so quickly.

    I’m using Windows XP (64-Bit) not Vista and yes I’m always the administrator.

    In my opinion VS2005 needs a “special” set up to produce 32-bit binaries when it is used on WinXP64 platforms. But I don’t know what settings I’ll need. The problem is none of the samples I tried (neither in C# nor in C++) could be installed on my 64-bit WinXP when I compiled those with VS2005. However, I can see that for example Notepad++ (nppcm by André Burgaud ;-) ) is resisted as Shell Extension.

    Do you have any idea to solve my problem except a usage of 32-bit-WinXP?

    Best regard
    Torsten

  21. #21 by Torsten Müller - January 3rd, 2009 at 09:49

    Hi André

    now I got the solution of my problem…

    I read anywhere in MSDN (e.g. Process Interoperability) it’s impossible to load a 32-bit DLL into a 64-bit process! I use a 64-bit Explorer on my 64-bit Windows XP and every source code example I tried beforehand was compiled as a 32-bit DLL!

    Sum: If I use a 64-bit OS I have to compile shell extensions as 64-bit binaries!

    Best regards
    Torsten

  22. #22 by Rosen Sharma - January 6th, 2009 at 18:52

    Hello André,

    great sample. is it possible to extend this to have 2 level menu?

    Rosen

  23. #23 by Omar - June 2nd, 2009 at 12:48

    Hi, I can’t install the dll, for me appears this message:

    Error in LoadLibrary(”wscitecm.dll”)-Application can’t be started because it’s configuration is incorrect, reinstalling application can fix the problem.

    What can be the problem or solution?

    My OS is Windows XP Service pack 3 (32 bits)

    Thanks

(will not be published)