Opening a website

This is a discussion on Opening a website within the C++ Programming forums, part of the General Programming Boards category; hey, i knda new to c programming so please don't be too harsh. anyway i would like to open a ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Location
    Ballincollig, co. cork, Eire
    Posts
    22

    Opening a website

    hey, i knda new to c programming so please don't be too harsh.
    anyway i would like to open a website using a c program. (eg. www.google.ie).
    does anyone know of a function that can do this?? would appreciate it if you do.

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    With open a website, are you talking about opening it in your default web browser?
    On Windows you can do
    Code:
    #include <stdlib.h>
    
    system("run www.google.ie");
    But know that system is pretty unsafe and you should do some checking before using it if it relies on user input, secondly while system() calls are portable that way of opening a web site only applies to Windows AFAIK so if you wan't something more portable you'd have to figure out some way to get the path to your webbrowser and replace "run" with that path.

  3. #3
    adr
    adr is offline
    Registered User
    Join Date
    Dec 2005
    Posts
    155
    Also you could use ShellExecute()
    Code:
    ShellExecute(NULL, TEXT("open") , TEXT("http://www.iland.net/"), NULL, NULL, SW_SHOWNORMAL);

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    1
    Quote Originally Posted by adr
    Also you could use ShellExecute()
    Code:
    ShellExecute(NULL, TEXT("open") , TEXT("http://www.iland.net/"), NULL, NULL, SW_SHOWNORMAL);
    does that work on both linux and windows?

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    University of Waterloo
    Posts
    1,903
    To clarify: Do you mean you would like to download the source code to the website or do you want to open the site inside of a browser?

  6. #6
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    No, ShellExecute is a Windows API function.

  7. #7
    Registered User
    Join Date
    Feb 2006
    Location
    Ballincollig, co. cork, Eire
    Posts
    22
    i would like to open the site in the browser. a friend in college recommended to use shellexecute and so did a lecturer in programming. the system("run ...") did not work, for me anyway.
    thanks for the help anyway

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How's my new Website
    By asbo60 in forum General Discussions
    Replies: 53
    Last Post: 07-10-2009, 10:10 AM
  2. Loading a Website
    By Borommakot in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2002, 05:07 PM

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