1
I try to develop a windows explorer context menu handler. I am new to this type of development. So I want to start with examples.
I started with SharpShell examples:
https://www.codeproject.com/Articles/512956/NET-Shell-Extensions-Shell-Context-Menus
Downloaded and compiled CountLinesExtension. However, I have problems with registering the extension.
I'm using Windows 10 Pro, version 1803.
I am using ShellExView to watch which DLL is registered to my Explorer.exe.
I'm using "Developer Command Prompt for VS2017" (with Administrator rights) to register my C# DLLs.
If I use "regasm CountLinesExtension.dll /codebase" command, ShellExView doesn't show any registed DLL. Also, Windows explorer context menus don't have my extension.
If I use 64-bit version of regasm: '"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" CountLinesExtension.dll /codebase', DLL register, but its path is incorrect.
ShellEx
"C:\WINDOWS\system32\C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/CountLinesExtension/v4.0_1.0.0.0__3abfeebd1a832fed/CountLinesExtension.dll"
this gif explains the situation very well
As you can see, file size is 0. Because there is no file on the path.
If I use 64 bit version of regasm without "/codebase" parameter: '"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" CountLinesExtension.dll'
the DLL registers to given path:
"C:\WINDOWS\assembly\GAC_MSIL\CountLinesExtension\1.0.0.0__3abfeebd1a832fed\CountLinesExtension.dll"
However, there is still no file on that path. File size is still zero.
And if I create the path manually, and copy the related DLLs to given path, DLL registers correctly.
As you can see, DLL registers on the correct path
However, windows explorer, still didn't show my extension on the context menu. I tried given type of (.txt, .log, etc...) files, however, that didn't work.
Also, I created another simple SharpShell ContextMenu project, to try logging. I added both info logs and error logs inside the code.
https://github.com/dwmkerr/sharpshell/blob/master/docs/logging/logging.md
I set SharpShell regedit log value to 7, which means log to file, windows event viewer, and DebugView.
However, log file (and Windows Event Viewer) only have registration and unregistration logs. If the DLL was installed correctly, my information and error logs should have been seen in the log file.
So, I gave up from SharpShell, and tried raw approach to shell extension development.
I downloaded CSShellExtContextMenuHandler from this URL: https://www.codeproject.com/Articles/174369/How-to-Write-Windows-Shell-Extension-with-NET-Lang
and compiled. Applied the same RegAsm steps. However, the result was the same. If I copy the DLL to given path in C:\Windows\System32{bla bla...}. DLL loads to windows explorer according to ShellExView, however never works.
So, I gave up from C#, I downloaded a C++ Context Menu Handler example from this URL:
https://code.msdn.microsoft.com/windowsapps/CppShellExtContextMenuHandl-410a709a
Compiled a 64 bit DLL. Opened "Windows CMD" with administrator rights and registered with "regsvr32 CppShellExtContextMenuHandler.dll" command. A message box shown that informs me about that the DLL registered successfully.
I can see the DLL in ShellExView, and it looked like that it is loaded correctly. However, I can't see anything in Windows Explorer context menus.
So, I need help registering (or compiling) the DLLs correctly.
Thanks for your help.