Opening the default browser with a specified URL

This is a discussion on Opening the default browser with a specified URL within the C++ Programming forums, part of the General Programming Boards category; Hi, here is my task. I need to create a program that will launch the user's default browser with a ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    79

    Opening the default browser with a specified URL

    Hi, here is my task. I need to create a program that will launch the user's default browser with a url that I specify. Is there any way to do it?
    Compiler:Borland C++ 5.0

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Yup...

    ShellExecute()...

    this has been answered loads of times...a few times by myself....try a search for more info

  3. #3
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    Hello. I tried using ShellExecute. This is the line I inserted...

    ShellExecute(handle,"open","c:\\Sundeep\\Directory \\Homepage.url",NULL,NULL,SW_SHOWMAXIMIZED);

    after including shellapi.h
    I am getting 26 errors, all to do with the file shellapi.h.

    A few examples of ShellExecute() would be helpful. You must have guessed, I am trying to launch the user's default browser to open the file Homepage.url located in the directory I have specified.

    Compiler:Borland C++ 5.0
    Last edited by sundeeptuteja; 08-04-2002 at 02:15 AM.

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    194
    What type of errors are you getting?
    shellapi.h comes with msvc++.
    First make sure you have the file on your computer. Use the windows search to do this.
    Look at borlands help, or online site to find out what header to include.

    I went to http://msdn.microsoft.com/ and searched for ShellExecute. This is what i found

    http://msdn.microsoft.com/library/de...ellexecute.asp

    if looks like you are using the function correctly, so it must be a compiler issue.

    I thaught Borland C++ 5.0 was only for dos apps. Or do you have Builder? im not to up to date with my borland knowledge, i have been using msvc++ for the past 2 years. Can you create windows applications?
    Maybe if you post your full source, or some of the error messages

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    Warn :shellapi.h(33,22):Style of function definition is now obsolete
    Error:shellapi.h(33,23):{ expected
    Error:shellapi.h(35,17):Declaration syntax error
    Error:shellapi.h(36,17):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(35,17):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(36,17):Declaration syntax error
    Error:shellapi.h(42,17):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(36,17):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(42,17):Declaration syntax error
    Error:shellapi.h(43,17):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(42,17):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(43,17):Declaration syntax error
    Error:shellapi.h(44,17):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(43,17):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(44,17):Declaration syntax error
    Error:shellapi.h(46,22):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(44,22):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(46,22):Declaration syntax error
    Error:shellapi.h(47,22):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(46,22):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(47,22):Declaration syntax error
    Error:shellapi.h(53,22):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(47,22):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(53,22):Declaration syntax error
    Error:shellapi.h(54,22):Multiple declaration for 'DECLSPEC_IMPORT'
    Error:shellapi.h(53,22):Earlier declaration of 'DECLSPEC_IMPORT'
    Error:shellapi.h(53,22):Too many error or warning messages

    Here are the errors I am getting. The whole source file is attached, please check it out. The function definition to look for is void update(). Look at line no. 1006.

    I tried searching the Borland help files, and found out that an import library has been specified, called shell32.lib, which does not seem to exist on my PC. I am assuming that the errors are caused because of this. Perhaps you could tell me where to get it, I could not find it on the Borland website. The file shellapi.h however does exist.

    Also, as I am just a 12th grade student, I haven't learnt anything about creating windows applications yet. So far all the programs I have created are DOS applications. I do not user Builder.

    Compiler:Borland C++ 5.0
    Attached Files Attached Files
    Last edited by sundeeptuteja; 08-05-2002 at 03:19 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about opening URL in Web-Browser
    By LeeDavies in forum C Programming
    Replies: 2
    Last Post: 05-02-2008, 06:14 PM
  2. Launching the default browser
    By darkknight1984 in forum C++ Programming
    Replies: 4
    Last Post: 06-10-2005, 08:43 AM
  3. Getting Default Browser and Running It
    By Driver in forum Windows Programming
    Replies: 4
    Last Post: 10-22-2004, 02:08 PM
  4. default browser and multiple users
    By Waldo2k2 in forum Tech Board
    Replies: 6
    Last Post: 10-05-2003, 12:03 PM
  5. How to detect and open the default browser
    By sundeeptuteja in forum C++ Programming
    Replies: 1
    Last Post: 06-30-2002, 11:32 AM

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