CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Invoke IE from VC++

    How I can load a HTML file from a Visual C++ program? I want to load that file into Internet Explorer. I have Visual C++ 5 Enterprise Version for Win95, Internet Explorer 3.0.


  2. #2
    Guest

    Re: Invoke IE from VC++

    Try using ShellExecute:

    CString sFile="c:\\my.html";// your html file path goes here
    HINSTANCE h = ShellExecute(NULL, "open", sFile, NULL, NULL, SW_SHOWNORMAL);

    I think that will work as long as IE is registered as the app for HTML files.
    If not it would find whichever browser the user has made default.







  3. #3
    Join Date
    Apr 1999
    Posts
    18

    Re: Invoke IE from VC++

    simply add this command to your code:
    ShellExecute(NULL,"open",URL,NULL,NULL,SW_SHOWNORMAL);

    (where URL is a string containing the HTML URL or file name to load)


  4. #4
    Join Date
    Apr 1999
    Location
    Pakistan
    Posts
    207

    Re: Invoke IE from VC++

    Thanks. I hope it will work.
    Zulfi


  5. #5
    Join Date
    Apr 1999
    Posts
    7

    Re: Invoke IE from VC++

    You should also "insert a IE ActiveX control" in a dialog box of your VC++ applications.
    Then "Add a member variable" on this control.
    And then call the following code:
    m_WebBrowser.Navigate( m_strURL, NULL, NULL, NULL, NULL);
    where m_WebBrowser is the member variable of the IE ActiveX object and m_strURL is your URL.



  6. #6
    Guest

    Re: Invoke IE from VC++

    On most systems (at least mine) the running ShellExecute with the URL as a parameter activates the most recently launched instance of IE and opens the URL in it. To open a NEW instance of IE, do this:

    ShellExecute(AfxGetApp()->GetMainWnd()->m_hWnd, NULL, "C:\\Program Files\\Plus!\\Microsoft Internet\\IEXPLORE.EXE", "http://www.codeguru.com", NULL, SW_SHOWNORMAL);

    This runs IE and sends the URL as a parameter. I assume something similar would work with Netscape.


    __________________________________________

    _=====_ Espen Zachrisen
    ========= Sloan School of Management
    ||||||||| MBA Class of 2000
    ========= Email: [email protected]
    MIT Sloan Tel: (781) 767-0417
    __________________________________________



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured