Results 1 to 5 of 5

Thread: [RESOLVED] Registry key for file types

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Resolved [RESOLVED] Registry key for file types

    I want my program to set registry keys to set a custom icon for files with *.eaf extensions.

    And also set my program as the default program to open those files...




    Thanks
    Last edited by winterslam; May 19th, 2007 at 11:36 PM.

  2. #2
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Registry key for file types

    It's pretty simple to do manually if your installer isn't getting it done.

    Add the following keys to your registry under HKEY_CLASSES_ROOT:

    Key: .eaf
    (default) value: Application.Document (Swap your app name for "Application")

    Key: Application.Document (Same swap as above)
    (default) value: Application File ("Type" that appears in explorer in details view)
    Subkey: Application.Document\DefaultIcon
    (default) value: Path & filename of icon file,0
    Subkey: Application.Document\shell
    Subkey: Application.Document\shell\open
    Subkey: Application.Document\shell\open\command
    (default) value: Path & filename of exe file %1

    Doing this makes all the logic work, but you still have one more step. You have to tell windows that the file associations have changed so that explorer will display the documents files with the correct icon, as well as show the appropriate "Type" description when in details view. To do this, send a ChangeNotify message:
    Code:
    Private Declare Sub SHChangeNotify Lib "shell32.dll" (ByVal wEventId As Long, ByVal uFlags As Long, dwItem1 As Any, dwItem2 As Any)
    
    ' Force Windows to refresh file associations
    Sub AssociateIcon()
        Const SHCNE_ASSOCCHANGED = &H8000000
        Const SHCNF_IDLIST = 0
        
        SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0&, 0&
    End Sub

  3. #3
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Registry key for file types

    Note that both the the AssociateIcon() function, as well as all the registry functions you need to add the appropriate keys are available in the library linked in my signature.

  4. #4
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Registry key for file types

    Also, if you're doing this manually, you should also add support to uninstall your application from Add/Remove Programs. First you need to write an uninstaller exe, which will delete the registry keys you created from above as well as remove the application files and folder under Program Files.

    Then, supply "Add/Remove Programs" with the information of your application and its uninstaller by adding the following key and values to the registry under HKEY_LOCAL_MACHINE:

    Key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Application
    (Note: Substitute your application name for "Application".)
    There is no (default) value for this key; instead, add the following string values under the key and set them appropriately:
    Contact (eg: winterslam)
    DisplayName (App name as displayed in the Add/Remove list)
    DisplayVersion (eg: 1.0)
    HelpLink (eg: [email protected] or www.SupportHomepage.com)
    InstallLocation (Path of main application folder)
    Publisher (Your company name)
    UninstallString (Path & filename of uninstall program)
    VersionMajor (eg: 1)
    VersionMinor (eg: 0)

    Assuming you do this, your uninstaller should also remove these registry keys/values after successfully uninstalling, and then should tell Windows to delete the uninstaller on next reboot. (Library linked in sig has a function for "delete on next reboot" as well.)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Posts
    146

    Re: Registry key for file types

    Thanks..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width