2

I have written this simplistic shell extension (explorer context menu) with SharpShell:

[ComVisible(true)]
[COMServerAssociation(AssociationType.AllFiles)]
public class SampleExtension : SharpContextMenu
{
    protected override bool CanShowMenu()
    {
        return true;
    }
    protected override ContextMenuStrip CreateMenu()
    {
        var menu = new ContextMenuStrip();
        var item = new ToolStripMenuItem
        {
            Text = "Hello world!"
        };
        menu.Items.Add(item);
        return menu;
    }
}

It works fine when I deploy it manually.

Based on William's instructions, I wrote the WiX script below to install the shell extension on 32bit PCs:

<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <Product Name='Sample Extension' Id='PUT-GUID-HERE' 
            UpgradeCode='PUT-GUID-HERE' Language='1033' Codepage='1252'
            Version='0.1.23' Manufacturer='Me'>

    <Package Id='*' Keywords='Installer' Description="Sample Extension Setup"
             Manufacturer='Me' InstallerVersion='200' Languages='1033' 
             Compressed='yes' SummaryCodepage='1252' InstallScope='perMachine'
             Platform='x86'/>

    <Media Id='1' Cabinet='SampleExtension.cab' EmbedCab='yes' 
           DiskPrompt='Sample CAB' />
    <Property Id='DiskPrompt' 
              Value="SampleExtension Bundle CAB Installation" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='INSTALLDIR' Name='SampleExtension'>
          <Component Id='Libraries' Guid='*'>
            <File Id='SampleExtension.dll' Name='SampleExtension.dll'
                  Source='SampleExtension\bin\Debug\SampleExtension.dll' 
                  DiskId='1' />
            <File Id='SharpShell.dll' Name='SharpShell.dll' 
                  Source='SampleExtension\bin\Debug\SharpShell.dll' 
                  DiskId='1' />
            <File Id="SrmExe" Source="Extras\srm.exe"/>
          </Component>
        </Directory>
      </Directory>
    </Directory>

    <CustomAction Id="InstallShell" FileKey="SrmExe" 
          ExeCommand='install "[INSTALLFOLDER]\Application.dll" -codebase'
          Execute="deferred" Return="check" Impersonate="no" />
    <CustomAction Id="UninstallShell" FileKey="SrmExe" 
          ExeCommand='uninstall "[INSTALLFOLDER]\Application.dll"'
          Execute="deferred" Return="check" Impersonate="no" />
    <InstallExecuteSequence>
      <Custom Action="InstallShell" 
        After="InstallFiles">NOT Installed
      </Custom>
      <Custom Action="UninstallShell" 
        Before="RemoveFiles">(NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
      </Custom>
    </InstallExecuteSequence>


    <Feature Id='SampleExtensionFeature' Title='Sample' Description='Sample' 
             Level='1' AllowAdvertise='no'>
      <ComponentRef Id="Libraries" />
    </Feature>

    <Property Id="MSIUSEREALADMINDETECTION" Value="1" />
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
    <WixVariable Id="WixUILicenseRtf" Value="license.rtf" />
    <UI><UIRef Id="WixUI_InstallDir" /></UI>
  </Product>
</Wix>

But after installing the MSI, the shell context menu does not appear. ShellExView does not even show it:

ShellExView SharpShell WiX

Here is the MSI log part that mentions srm, it is not really understandable for me:

Executing op: FileCopy(SourceName=srm.exe,SourceCabKey=SrmExe,DestName=srm.exe,Attributes=512,FileSize=151552,PerTick=65536,,VerifyMedia=1,,,,,CheckCRC=0,Version=2.1.0.0,Language=0,InstallMode=58982400,,,,,,,)
File: C:\Program Files\CmisSyncShellExtension\srm.exe;  To be installed;    Won't patch;    No existing file
Source for file 'SrmExe' is compressed
InstallFiles: File: srm.exe,  Directory: C:\Program Files\CmisSyncShellExtension\,  Size: 151552
Executing op: CacheSizeFlush(,)
Executing op: ActionStart(Name=InstallShell,,)
Action 18:30:13: InstallShell. 
Executing op: CustomActionSchedule(Action=InstallShell,ActionType=3090,Source=C:\Program Files\CmisSyncShellExtension\srm.exe,Target=install "\Application.dll" -codebase,)
Executing op: ActionStart(Name=RegisterProduct,Description=Registering product,Template=[1])
Action 18:30:13: RegisterProduct. Registering product
Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373
  • Could it be a x86 vs x64 platform issue? – Simon Mourier Aug 22 '14 at 06:34
  • @SimonMourier: I am only interested in 32bit for now. The machine on which I compiled the DLLs, built and tried the MSI is 32bit. No file has ever touched anything 64bit. – Nicolas Raoul Aug 22 '14 at 06:59
  • Have you tried to create an msi log? "msiexec /i [put msi path here].msi /l*v install.log" – Simon Mourier Aug 22 '14 at 08:04
  • @SimonMourier: Good idea! I added the MSI log. – Nicolas Raoul Aug 22 '14 at 08:28
  • Is the srm thing doing its job? do you see its output? Have you tried the "Server Manager" tool that comes with SharpShell? You can also use the procmon tool from sysinternals to see what's written or not to the registry. – Simon Mourier Aug 22 '14 at 09:04
  • @SimonMourier: Nothing else about `srm` appears in the MSI log, and no particular errors are shown. It works using ServerManager's `Register Server (x86)`, the context menu works and appears in ShellExView. I am having some trouble running `srm.exe` from command line though: http://stackoverflow.com/q/25440626 – Nicolas Raoul Aug 22 '14 at 09:12

0 Answers0