Easy on - making a link

This is a discussion on Easy on - making a link within the C++ Programming forums, part of the General Programming Boards category; Hi there!! I've got a question concerning the internet. The question is easy. How can I make my program open ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    105

    Easy on - making a link

    Hi there!!

    I've got a question concerning the internet. The question is easy. How can I make my program open a webpage with the default browser? Is there a component which makes this?

    Thx
    Han

  2. #2
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Code:
    HINSTANCE ShellExecute(
        HWND hwnd, 
        LPCTSTR lpOperation,
        LPCTSTR lpFile, 
        LPCTSTR lpParameters, 
        LPCTSTR lpDirectory,
        INT nShowCmd
    );
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    This is just what I wanted to avoid... But if there's no other way....

  4. #4
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Not one that I personally know of.
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  5. #5
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Arrow wow that sounds cool

    how exactly does that work?

    It sounds like a cool thing to have happen.

    I do not see url, so how would it know where to go?

    Is that all the code you need?

    Does it require a special header file?
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  6. #6
    Master of the Universe! velius's Avatar
    Join Date
    Sep 2003
    Posts
    219
    Read up on it at www.msdn.microsoft.com It requires windows.h
    While you're breakin' down my back n'
    I been rackin' out my brain
    It don't matter how we make it
    'Cause it always ends the same
    You can push it for more mileage
    But your flaps r' wearin' thin
    And I could sleep on it 'til mornin'
    But this nightmare never ends
    Don't forget to call my lawyers
    With ridiculous demands
    An you can take the pity so far
    But it's more than I can stand
    'Cause this couchtrip's gettin' older
    Tell me how long has it been
    'Cause 5 years is forever
    An you haven't grown up yet
    -- You Could Be Mine - Guns N' Roses

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    Well using Shellexecute is quite problematic....
    I've got a problem with putting the contents of a String into a *char.

    I usually get an error.
    My code is:
    Code:
    Error = (int) ShellExecute(NULL,
                                   "open",
                                   filebuffer,
                                   NULL,
                                   NULL,
                                   SW_SHOWNORMAL);
    Here filebuffer is a *char array. I won't use constants, since I can't. The web address I'd like to use isn't always the same. However I tried with a constant web address, and it worked so there's nothing wrong with Shellexecute. I only don't know how to use a *char array with it.

  8. #8
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Unspecific link

    Could you be more specific with your link.
    I"m assuming you are talking about c++, but
    I see stuff on VB. Is it VB code?
    What should I look for to find it?
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

  9. #9
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    It's quite weird though..
    I try to open the page... pardon me, the contents of filebuffer and I get it's contents back in a msgbox and nothing else happens.

  10. #10
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    The error code it gives is 5... What does that mean? Where can I look it up? msdn.msoft.com isn't quite the best place.. However, I use Borland C++Builder..

  11. #11
    twm
    twm is offline
    root
    Join Date
    Sep 2003
    Posts
    232
    >The error code it gives is 5...
    #define SE_ERR_ACCESSDENIED 5 // access denied

    and

    ShellExecute
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  12. #12
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Well, if you get an error, VS has a thing called error lookup... but there's no one for Borland I fear. However, there's a header called winerror.h in which you should take a look. By doing so, I found that error 5L is defined as ERROR_ACCESS_DENIED and by searching into my Platform SDK collection, I found that it corresponds to:
    SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
    Even if twm gave you the answer, you should remember the ehader.

    Anyway, there seems not to be any problems with char * as the parameter expected is a char *. The only condition is that it must be null-terminated.

    Could you be more specific with your link.
    I"m assuming you are talking about c++, but
    I see stuff on VB. Is it VB code?
    What should I look for to find it?
    Nothing about VB here but as Widnows API and all MS stuffs are VB compatible, the function is as well. Besides MSDN provide both examples.

    If you are interested in Windows programming, you should definitely take the Platform SDK with its documentation all available at MSDN. (somewhere, you have to search)

  13. #13
    Registered User
    Join Date
    Mar 2003
    Posts
    105
    It works now. Don't ask me how, but it works. When I check the filebuffer during debugging, I see the webaddress plus some stupid characters.. And guess what... it opens the specified web address..
    So I hope it'll work fine from now on...

  14. #14
    lyx
    lyx is offline
    Amateur
    Join Date
    Sep 2003
    Posts
    228
    Never rely on luck...

  15. #15
    essence of digital xddxogm3's Avatar
    Join Date
    Sep 2003
    Posts
    589

    Question Windows programming

    Does this mean if I'm programming for the command line promp I will not be able to use this capability?

    I'm currently learning command line, and have not even touched the gui or window interface yet. Will this restrict me from doing this?
    "Hence to fight and conquer in all your battles is not supreme excellence;
    supreme excellence consists in breaking the enemy's resistance without fighting."
    Art of War Sun Tzu

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. ad-hoc link causing loop
    By Waldo2k2 in forum Networking/Device Communication
    Replies: 3
    Last Post: 04-11-2005, 10:09 PM
  2. Data structure implementation
    By fkheng in forum C Programming
    Replies: 3
    Last Post: 07-31-2003, 07:44 AM
  3. Undefined Structure in Link List
    By _Cl0wn_ in forum C Programming
    Replies: 1
    Last Post: 03-22-2003, 04:57 PM
  4. link list
    By volk in forum C Programming
    Replies: 2
    Last Post: 03-07-2003, 03:02 PM
  5. Debugging link error
    By bubux in forum C Programming
    Replies: 5
    Last Post: 07-06-2002, 02:19 PM

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