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.
Here is the C++ source code
#define _WIN32_WINNT 0x0500
#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
#include
#include
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.