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.

,

  • http://www.bitcore.de Hajo Schlingensief

    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

  • http://www.burgaud.com/ André Burgaud

    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é -

  • http://www.WarpEngine.com Abel

    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

  • http://www.burgaud.com André Burgaud

    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é -

  • Paul

    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.

  • http://www.burgaud.com André Burgaud

    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é -

  • Kun

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

  • http://timebend.com Naveed

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

  • http://www.burgaud.com André Burgaud

    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é -

  • Jorr

    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.

  • Jorr

    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..

  • http://www.burgaud.com André Burgaud

    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é -

  • Jorr

    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)

  • http://www.warpengine.com Abel

    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

  • http://www.burgaud.com André Burgaud

    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é -

  • Jason Black

    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.

  • http://www.burgaud.com André Burgaud

    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é-

  • Torsten Müller

    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

  • http://www.burgaud.com André Burgaud

    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é-

  • Torsten Müller

    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

  • Torsten Müller

    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

  • http://think-smarter.com Rosen Sharma

    Hello André,

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

    Rosen

  • Pingback: Explorer Shell extension | keyongtech

  • http://www.chinamx.qsh.es Omar

    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

  • DAK

    Hi,

    I’m having trouble compiling the DLL; and I think it’s because of the version of WIN32.MAK I’m using. Can you post the file with which you’ve successfully compiled this DLL, or let us know where I can download it? Thanks!

  • fiery

    André Burgaud :

    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é-

    That was exactly what solved my problem on Windows 7. The SciTE setup provided by Bruce Dodson just fails if shell extension is installed. So I tried to install this extension manually. If Command Prompt is not run as Administrator the following error appears: 0×80004005. So it would be fine if you add some comments about this problem in the Read Me.

  • Leslie Harper

    I just wanted to say thank you for posting this code. I found it after barking up the wrong tree for days trying to do the same thing using managed code.

    I did have a problem when compling – I got a file not found error when the mt.exe part of the build ran (it seems as if the .manifest file is missing. The dll was still created and it works so I’m not sure if it’s a big deal. I’m compiling using the VS 2010 beta on Windows 7 x64 if that explains anything.

  • Daniel

    The errors

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

    and

    “Generate Activation Context failed for C:\Program Files\Scintilla Text Editor\wscitecm.dll. Reference error message: The referenced assembly is not installed on your system.”

    are resolved by installing Visual C++ 2005 Redistributable Service Pack 1 (SP1).

  • http://www.ceremoni.se Caspar @ Bröllopsdekorationer

    @ Daniel

    I had the same errors bur it went away just by re installing the 2005 redistibutable service pack and then restarting.

    Hope it works for you!

    // Caspar

  • Steven

    I can usually get it working but when I try to edit a system file (such as “hosts”) it doesn’t let me. I assume I need to ALWAYS run scite as administrator so I go into its properties and check that option. However, when right-click any file and open with SciTE it would give me: “Error creating process: wscitecm.dll needs to be in the same directory as SciTe.exe”. Any thoughts? I’m on Windows 7×64.

  • http://www.superautomaticespressomachines.net Clark Rivers

    This extension is absolutely fantastic to work with. I had installation issues until I used the setup provided by Bruce Dodson & C++ redistribution packs. It works really fine. Thanks for you help. It was very infomative.Hats Off.

  • http://linkup.com.ua LinkUp

    its absolutely fantastic!!

  • http://www.squidoo.com/best-kettlebell-workouts Ben Walker

    Thanks for this awesome resource Andre. Smart, easy to follow instructions to install this extension. Can you say…too easy?

    Thanks again!

  • http://www.tacticaltomahawkreviews.com/ Corican

    Great post, thanks a lot! It saved me much time