_ap_ufes{"success":true,"siteUrl":"www.jucktion.com/tech","urls":{"Home":"https://www.jucktion.com/tech","Category":"https://www.jucktion.com/tech/c/mobile/android/","Archive":"https://www.jucktion.com/tech/2017/11/","Post":"https://www.jucktion.com/tech/pushbullet-notifications-automated-browser-testing/","Page":"https://www.jucktion.com/tech/about/","Attachment":"https://www.jucktion.com/tech/pushbullet-notifications-automated-browser-testing/pushbullet-web-test-complete-notification/","Nav_menu_item":"https://www.jucktion.com/tech/3985/"}}_ap_ufee Open Web Page in C++

Open Web Page in C++

By | 25th June, 2011 | 0 Comments

Here’s a simple code in C++ that you can use to open web page in the default browser in Windows. The code uses ShellExecute function to open up the default browser and open the web page you want. This code is compiled and tested using MinGW Compiler.

open web page in c

Here is the C++ source code

#define _WIN32_WINNT 0x0500
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")

int main()
HWND hWnd = GetConsoleWindow();
ShowWindow( hWnd, SW_HIDE );
ShellExecute(NULL,TEXT("open"), TEXT("http://www.jucktion.com/tech"), TEXT(""),NULL,SW_HIDE);
return 0;

The code uses the windows.h host file so make sure you have it. The SW_HIDE code is used to hide the window when the program is executed but the dos program opens for a brief second.

If anyone has a better suggestions feel free to recommend a better code.

Tags: , , ,

Category: Cool Hacks, How To's, Windows