MSDN Library

File Association Sample Scenario

In the following example, a hypothetical software development company called Litware, Inc. creates a new audio player called LitwarePlayer. Litware wants to design a file association between LitwarePlayer and its primary file type, which uses a newly developed audio format that enables an entire audio CD to be stored in less than 10 kilobytes of memory with no loss of quality. The company should take the following steps.

  1. Decide if the new file type should be treated as public or private. This new file type is a media type. Because users exchange media files across various platforms and there might be other applications that need to read the LitwarePlayer format, a public file type is the most appropriate.
  2. Determine if this file type is already defined. Check the Internet Assigned Numbers Authority (IANA) MIME database, and other public file type databases on the Internet to determine that no comparable file type has been defined. Because this is a new file format, you need to define a new file.
  3. Define an extension for the new file type. The developers choose the first long extension .opa-ltw-audio, which incorporates their vendor abbreviation and a hint about the what the file contains into the long extension. Research determines that the extension is not being used by anyone else. Following current recommendations, no short extension is defined.
  4. Define a MIME type for the file type and register with the IANA. Litware defines the new MIME type as audio/LitwarePlayer.1 and prepares a MIME type application, following the guidelines laid out in Request for Comments (RFC) numbers 2045, 2046, 2047, and 2048. They then submit the application to the IANA, who adds the new file type to the database of registered MIME types.
  5. Determine if a ProgID exists for the file type. Because this is a new file type, no ProgID exists for it. Litware sets about designing a new ProgID for LitwarePlayer. They decide on the friendly name "LitwarePlayer Audio Player" (which is stored as a resource in the LitwarePlayer.exe file) and design a default icon to use for files associated with LitwarePlayer (also stored in LitwarePlayer.exe). Because LitwarePlayer is a new application, this is a version 1 ProgID.
  6. Register the ProgID. When LitwarePlayer is installed, the installation program creates the following ProgID entry in the registry.

      • Litware.LitwarePlayer.1

      • (Default) = LitwarePlayer Audio Player
        FriendlyTypeName = @LitwarePlayer, -120
        • CurVer

        • (Default) = Litware.LitwarePlayer.1
        • DefaultIcon

        • (Default) = LitwarePlayer, -142
        • shell
          • play
            • command

            • (Default) = "%ProgramFiles%\LitwarePlayer\LitwarePlayer.exe" "%1"

    In the command key, %1 is passed as the path to the file to play.

  7. Register the extension for the file type. When LitwarePlayer is installed, the installation program creates the following entries in the registry for its custom file type extension.

      • .opa-vwi-audio

      • (Default) = Litware.LitwarePlayer.1
        PerceivedType = Audio
        Content Type = audio/LitwarePlayer
Note  Any time a file association is created or changed, notify the system that a change has been made by calling SHChangeNotify, specifying the SHCNE_ASSOCCHANGED event. If this is not done, the Shell might not recognize any changes made until the system restarts.

Community Additions

© 2015 Microsoft