Using C++ To Launch A URL?

Newbie Spellweaver
Joined
Dec 23, 2011
Messages
24
Reaction score
1
Hello, i have been trying to use C++ to launch a URL. I am not very good at c++ and know very little.

this is the code, i have been using : -

#include <windows.h>

void main()
{
ShellExecute(NULL, "open", "http://google.co.uk",
NULL, NULL, SW_SHOWNORMAL);
}

but i get an error messgae, can anyone write me up a new code or correct this one? tyvm :love:
 
....

try:
Code:
#include <windows.h>

int main(){
ShellExecute(NULL, "open", "http://google.co.uk",
NULL, NULL, SW_SHOWNORMAL);
}
 
You could use nanosleep, since there's no real sleep function in c++.

or use

#include <time.h>

void slp(unsigned int mseconds)
{
clock_t goali = mseconds + clock();
while (goali > clock());
}

then slp(milliseconshere)
 
You could use nanosleep, since there's no real sleep function in c++.

or use

#include <time.h>

void slp(unsigned int mseconds)
{
clock_t goali = mseconds + clock();
while (goali > clock());
}

then slp(milliseconshere)

Sleep is platform dependent, primarily because it generally falls in line with threading and there is no standardized threading. Win32 provides a Sleep function http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298(v=vs.85).aspx.

You should never do a busy sleep though, ever.
 
Back