7 Replies - 4234 Views - Last Post: 29 December 2012 - 05:14 AM

#1 dec1pher   User is offline

  • D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 116
  • Joined: 27-January 06

open a url in the default web browser

Posted 29 January 2006 - 05:34 AM

Description: easy to use... well almost cheap. no need to use ie if firefox is your default browser so it fires up firefox then opens the specified url...
#include <windows.h>

int main()
{
   ShellExecute(NULL, "open", "http://dreamincode.net",
                NULL, NULL, SW_SHOWNORMAL);
   return 0;
}

Is This A Good Question/Topic? 1
  • +

Replies To: open a url in the default web browser

#2 munyu   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 18-October 07

Re: open a url in the default web browser

Posted 24 January 2008 - 06:36 AM

nice one for beginner
Was This Post Helpful? 0
  • +
  • -

#3 C++ Programmer   User is offline

  • D.I.C Addict
  • member icon

Reputation: 20
  • View blog
  • Posts: 548
  • Joined: 12-June 08

Re: open a url in the default web browser

Posted 10 July 2008 - 09:22 AM

Nice, been trying to do this
Was This Post Helpful? 0
  • +
  • -

#4 Zerobu   User is offline

  • Black Hatter

Reputation: 13
  • View blog
  • Posts: 1,822
  • Joined: 14-January 08

Re: open a url in the default web browser

Posted 11 June 2009 - 12:29 PM

Imagine what fun you can do with a loop!
Was This Post Helpful? 0
  • +
  • -

#5 physicsboy   User is offline

  • New D.I.C Head
  • member icon

Reputation: -1
  • View blog
  • Posts: 10
  • Joined: 28-September 09

Re: open a url in the default web browser

Posted 19 November 2009 - 05:54 AM

Great job, I've been trying to figure that out.
Was This Post Helpful? 0
  • +
  • -

#6 rukmani   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 21-November 12

Re: open a url in the default web browser

Posted 21 November 2012 - 02:53 PM

This code did not work for me. It went on showing me the error ShellExecuteW:cannot convert parameter 2 from 'const char[5]' to LPCWSTR. I have no clue what to do
Was This Post Helpful? 0
  • +
  • -

#7 rukmani   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 21-November 12

Re: open a url in the default web browser

Posted 21 November 2012 - 03:21 PM

I got it working finally. I included #include include directory and changed the code as L"open" to accept large values. I am using Visual Studios 2008 and so I had to include L"open"
Was This Post Helpful? 0
  • +
  • -

#8 anup.pande   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 29-December 12

Re: open a url in the default web browser

Posted 29 December 2012 - 05:14 AM

hi rukmini you are using unicode function which is ShellExecuteW . . so if u are using char array then use wchar_t . . or u can run it likeShellExecute(NULL,L"open",L"http://dreamincode.net",NULL, NULL, SW_SHOWNORMAL);
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1