Thread: Opening a .html file with Internet Explorer programmatically

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    204

    Opening a .html file with Internet Explorer programmatically

    Here's the scenario:
    OS: Windows XP
    program.exe is in C:\foobar
    program.exe creates foobar.html and puts it in C:\foobar

    Here's the question:
    How can I open foobar.html with Internet Explorer using the system() function? Thanks.

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    7
    Try it in "cmd" or "command" *first*

    now
    "start c:\Progra~1\Intern~1\ie.exe pathtohtmlfile"
    stdlib.h:system("start c:\Progra~1\Intern~1\ie.exe pathtohtmlfile");
    (this should work, old msdos tricks )

    NOTE: I haven't had a windows computer in front of me for about 8 months, so don't count on it exactly

  3. #3
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,273
    Code:
    system("\"c:\\program files\\internet explorer\\iexplore.exe\" C:\\foobar\\foobar.html");
    The problem with this would be that there is no guarantee that Internet Explorer will be at the path I've given, so you'd need to start using Windows API calls to find it or its equivalent, such as Firefox.

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    7
    oh yea, forgot about that escaping problem, ha.

    I think your better off using "C:/program files/style path"

  5. #5
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    you might try using either a relative path (\\program files\\blah...) or getenv() systemdrive

  6. #6

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    FAQ: http://faq.cprogramming.com/cgi-bin/...&id=1043284392
    (contains shellexecute example)
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  2. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  3. Opening a .html file from the console
    By Verdagon in forum C++ Programming
    Replies: 9
    Last Post: 08-02-2005, 05:05 AM
  4. Encryption program
    By zeiffelz in forum C Programming
    Replies: 1
    Last Post: 06-15-2005, 03:39 AM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM