Skip to content

How to package your application with Dokan

Liryna edited this page Dec 30, 2021 · 6 revisions

Dokan versioning

Dokan adheres to Semantic Versioning

Given a version number MAJOR.MINOR.PATCH, increment the:

  • MAJOR version when incompatible changes in communication between kernel driver and library are made.
  • MINOR version when functionality in the library or kernel are added but an older library would still work with the new kernel.
  • PATCH version when bug fixes backwards-compatible are made.

MAJOR version is embedded in Dokan library (dokan2.dll) and kernel (dokan2.sys) names.

MSI files and WiX

Dokan releases include two MSI setup files for the x64 and x86 drivers. You can include just the MSI files in your project but keep in mind other software required by Dokan as demonstrated in the dokan_wix\Bootstrapper\Bundle.wxs file (i.e. Visual Studio 2017 redist files, various Windows KB updates).

To add the MSIs into your own WiX bundle you can copy the MsiPackage lines for Dokan_x86.msi and Dokan_x64.msi from the Dokan bundle.wxs.

Check for previous Dokan installations

The Dokan driver can not be installed as an upgrade becausee it requires an intermittent reboot for the uninstall of an existing version. Your bootstrapper or setup executable should check for previous Dokan installations or at least correctly interpret the corresponding MSI error, the MSI will return error code 1603.

If your setup includes an older compatible Dokan version it should skip attempting to install the obsolete version. WiX bundles check for obsolete MSI versions automatically.

To detect if a previous version of dokan is installed with the same major API, you simply should check if dokan driver is present in C:\Windows\System32\drivers. Example: Dokany 2.x.x -> C:\Windows\System32\drivers\dokan2.sys.

Dokan version considerations

Dokan Kernel driver and library use a global device name to communicate. This device name contains the MAJOR version at the end (i.e. Dokan2). This means different Dokan MAJOR versions can be installed side by side. For example, legacy 0.6.0 Dokan can be used on the same system where 1.0.0 Dokan version is installed.

Two dokan installers with the same MAJOR version and different MINOR version cannot be installed side by side. Only one of these installers can be installed.

Dokan installers require a reboot to fully unload and uninstall the driver file. This behavior might be fixed in the future if and when Dokan supports PnP.

Your installer should only remove Dokan if you are sure that no other applications are using it. See https://github.com/dokan-dev/dokany/issues/322

Dokan application considerations

Dokan installs the library in {windir}\system32 on purpose to be used by all installed Dokan applications.

BUT since it is possible that Dokan library will be updated by another Dokan application, the update might break link dependency to your application. Therefore it is highly recommended embedding the dokan2.dll in your application folder. Doing this will retain compatibility of your application with all MAJOR versions equal to the library you embed.