CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Double Click on File

  1. #1
    Join Date
    Aug 2000

    Double Click on File

    Please some one told me that how to attach a file to an application such that when i Double Click the file then it is opened in the same attached application e.g. when .txt file is Double Clicked then it is opened in the Notepad. similar task is required to me. Please give me any hint.
    Thanks in advance

  2. #2
    Join Date
    Oct 1999
    Johannesburg, Gauteng, South Africa

    Re: Double Click on File

    You can register new file extensions using Windows Explorer (explorer.exe) under the Tools menu, alternatively you can set associations using regedit and a .reg file or writing the required registry keys programmatically.

    You can execute the file-associated application using the Shell functions 'ShellExecute' or ShellExecuteEx' functions.

  3. #3
    Join Date
    Nov 1999
    Dresden / Germoney

    Re: Double Click on File

    This information is written to the registry.

    for example, for .txt ==> Notepad:

    the key "HKEY_CLASSES_ROOT\.txt" has the default value "txtfile"
    this assigns the ".txt" extension to a certain type of file, namely "txtfile".
    under "HKEY_CLASSES_ROOT\txtfile\shell" we find a list of sub keys with available operations, on my system it's


    for each sub key, the default value indicates the name displayed in the context menu, and another subkey "command" indicates the command to execute.

    if no other default operation is specified, "open" will be taken as default for the double click

    so the default value of "HKEY_CLASSES_ROOT\txtfile\shell\open\command" contains the command line to execute for .txt files.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)