Register your application to scanner events

Since version 1.44, iCopy (the installer version) supports the possibility to be launched by pressing the scanner button.

This is made possible by Microsoft STI Still Image application API. The application is added to the scanner button handlers by adding some registry keys. Here is how.

Note: You must know the GUID of your application. For .NET applications, like iCopy, the GUID can be retrieved at runtime with some lines of code or in the assembly propeties.

iCopy GUID is {18774F05-0CCB-48C5-ADFA-67F81C4BC33D}

The values that need to be created are under these keys (replace the blue parts between square brackets with values suitable for your program):

  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\

    Under this key, add a new Key with the name WIA_{[GUID]}

    Inside the key you have just created, add these string values:

    Name Value
    Action [Your description]
    DefaultIcon sti.dll,0
    InitCmdline /WiaCmd;[PROGRAM EXECUTABLE PATH] /StiDevice:%1 /StiEvent:%2;
    Provider [Program Name]

    The executable path must be complete of program name and .exe extension. Example:

    C:\Program Files\iCopy\icopy.exe
  • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
    StillImage\Registered Applications

    Under this key, add a string value with Name [Program Name] and Value [Executable Path]

  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StillImage\

    Under this key, add a new key and call it with your program GUID in { } brackets. Then add the following string values:

    Name Value
    Cmdline [Executable Path] /StiDevice:%1 /StiEvent:%2
    Desc [Your description]
    Icon [An icon, either embedded in the exe or not]
    Name [Program Name]

Note that the program won’t be recognized until next system restart

Of course to remove the program to the listing, simply remove the keys you created before.

Here is an example of the keys that iCopy adds to the registry:

I included these values in iCopy installer as an option. Of course the portable version can’t have this feature because it would modify the registry, which is against portability definition.

There is a C++ header inside Windows SDK that provides an interface to these API (sti.h), but I couldn’t get it to work with VB.NET nor with C#, so I preferred the manual way.