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

Thread: Double Click on File

  1. #1
    Join Date
    Aug 2000
    Location
    Islamabad,Pakistan
    Posts
    89

    Double Click on File

    Hi!
    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
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    89

    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
    Location
    Dresden / Germoney
    Posts
    1,402

    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

    open
    EditWithVS
    print

    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)