Skip to main content
gamedev.net
🔒 Locked

Something simple, I think.

Started by The C modest god Sep 2, 2005 at 10:53 AM 1 replies 750+ views
Original Post
The C modest god
The C modest god
I would like my program to open an explorer window in a certain website, when a button is being pressed. I am programming in visual C++ 6. I think this should be simple. How do I do that? Thanks in advance.
It's all about the wheel.Never blindly trust technoligy.I love my internal organs.Real men don't shower. Quote: Original post by Toolmaker Quote:
Illco
Illco
You can offer the URL as a string to the OS which will open it using the default program for that file type (for HTML for example that will be the user's default browser). In Windows this can be done using ShellExecute() if I remember well. But perhaps this is not the best solution.

Greetz,

Illco
helix
helix
Here's the function we use in our engine for this sort of thing (slightly stripped down for readability):

bool SpawnActive( HANDLE hApp )	// handle to app that we will query{	BOOL	bAppQuery;	DWORD	Status = 0;	// fail if we have a bad handle	if ( hApp == NULL )	{		assert( 0 );		return false;	}	// get app status	bAppQuery = GetExitCodeProcess( hApp, &Status );	if ( AppQuery == false )	{		return false;	}	// return app status	if ( STILL_ACTIVE == Status )	{		return true;	}	return false;}HANDLE SpawnApp( char *pLaunchString, const char *pParameters, bool bSynchronous ){	SHELLEXECUTEINFO	ShellInfo;	// Init ShellInfo struct	memset( &ShellInfo, 0, sizeof( SHELLEXECUTEINFO ) );	ShellInfo.cbSize = sizeof( SHELLEXECUTEINFO );	ShellInfo.fMask = SEE_MASK_NOCLOSEPROCESS;	ShellInfo.nShow = SW_SHOWNORMAL;	ShellInfo.lpFile = pLaunchString;	ShellInfo.lpParameters = pParameters;	// launch new process	if ( ShellExecuteEx( &ShellInfo ) == 0 )	{		return NULL;	}	// If its a synchronous spawn, then wait for the app to finish then null its handle	if ( bSynchronous )	{		while ( SpawnActive( ShellInfo.hProcess ) );		ShellInfo.hProcess = NULL;	}	::ShowWindow( ShellInfo.hwnd, SW_SHOWNORMAL );	::SetForegroundWindow( ShellInfo.hwnd );	::SetFocus( ShellInfo.hwnd );	// return spawed app handle process	return ShellInfo.hProcess;}


So make the call something like this:
SpawnApp( "iexplore.exe", "http://www.gamedev.net", false );

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.