opening html files in application

This is a discussion on opening html files in application within the Windows Programming forums, part of the Platform Specific Boards category; hi, i have a button, and when clicked, i would like it to open an html file, i searched MSDN ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    52

    opening html files in application

    hi, i have a button, and when clicked, i would like it to open an html file, i searched MSDN and i looked through my book, i can't find anything to do this. can someone please help? ok thank you

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Do you want to open it with the default browser? If so, check out ShellExecute. Simple example here
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    52
    well, i basically want to click a button(this is all MFC stuff i did) and then it opens up IE and my html page is there. With all the documentation i need.

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    52
    that link you provided seemed somewhat helpful but when i tried to use it, it wouldnt open up my html document, i think it just opens up .exe's.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    52
    anyone else might know? i checked all the documentation i had, and all it says is how to open up executables, when i tried to use my html file, nothing happened, i used the WinExec function and that didnt work..

  6. #6
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    If you use ShellExecute and pass the URL as the file name, then it should open it in the default browser.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  7. #7
    Registered User johnnie2's Avatar
    Join Date
    Aug 2001
    Posts
    186
    Originally posted by Ripper1
    that link you provided seemed somewhat helpful but when i tried to use it, it wouldnt open up my html document, i think it just opens up .exe's.
    Right. You'll have to specify the browser executable (iexplore.exe for Internet Explorer) and the path to your HTML document as the parameter field. The operation to perform should remain "open," as shown in the example.
    "Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Originally posted by Ripper1
    that link you provided seemed somewhat helpful but when i tried to use it, it wouldnt open up my html document, i think it just opens up .exe's.
    No, it opens up files with whatever the default program for that file type is - in the case of url's it will be your browser. There should be no need to specify the program name for this use.

    Replace 'szPath' in the FAQ example with your url. Your default browser should be launched with that webpage open (provided you have an active internet connection otherwise your browser should report an error). If that doesn't work, replace the SW_SHOW with SW_SHOWDEFAULT as the last parameter.

    In either case, read up on ShellExecute.

    If you still have problems - and you have remembered to link with the correct library (shell32.lib with msvc,bcc5.5; libshell32.a with mingw) - then post how you are using it.

    BTW, WinExec is obsolete.

  9. #9
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    there is also another easy way to do it:


    system("explorer.exe http://website.goes.here.com");

    and that launches up the explorer and automatically goes to that site (can also be used for browsing)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opening files.
    By omnificient in forum C Programming
    Replies: 9
    Last Post: 02-25-2008, 01:05 PM
  2. Opening ASCII files in C?
    By Mavix in forum C Programming
    Replies: 6
    Last Post: 04-25-2007, 02:23 PM
  3. opening files sequentially
    By barneygumble742 in forum C++ Programming
    Replies: 9
    Last Post: 12-21-2006, 10:26 AM
  4. Replies: 2
    Last Post: 11-05-2001, 01:02 PM
  5. Opening files - Giving options?
    By wwwGazUKcom in forum C++ Programming
    Replies: 3
    Last Post: 09-18-2001, 07:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21