Thread: Open With - How do i usethis?

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    3

    Question Open With - How do i usethis?

    As most people probably have, i've just completed my own version of notepad.....but i was wondering how i'd get the program to open the text file, if a user right clicks on the file icon, and selects open-with, and selects my program?????????

    I've searched all over, with no joy, please help.

  2. #2
    I think it has something to do with registers.
    maybe you can do a search in your registers with "open" or "ContextMenuHandlers"


    It isn't much, but I hope this puts you in the right direction

  3. #3
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Easiest way:

    Open Windows explorer. Hold down the Ctrl-Key and right-click on a text file. Select "Open with...". If you are on 2K, choose "Select Application..." from the submenu. Now you see a list of applications. Select yours, check the "Always open filetype with this application" checkbox at the bottom. Press ok.

    ( Texts may vary, I only have a german version, texts are my translation )

    ----- Edit:

    I think I misunderstood your question. When you do this, your program will be called with the name of the file as the first commandline parameter. You can then open the file in your program.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    you need to set it in a key the registry. under HKEY_CLASSES_ROOT\.filetype set the default value to your app's location every time it starts.

    Then you need to look at the second-to-last argument of WinMain() contains the command-line parameters passed to your app. So you can use that with fopen or CreateFile and read in the file that opened your app and display it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open Source Licenses
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 10-10-2006, 08:53 PM
  2. Big help in Astar search code...
    By alvifarooq in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2004, 11:38 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Problems with open and save boxes
    By pinkcheese in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2002, 06:03 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM