News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How can I open the default mail or browser program when the user clicks on an URL?

By Daniel Strigl, March 02, 2004.
Print version

Question

I want to open the default mail or browser program when the user clicks on an URL like "mailto:email@pocketpcdn.com" or "http://www.hh-system.com/danielstrigl". How can it be done?

Answer

That's simple... just call the ShellExecuteEx API function with the correct parameters. Here is sample code:

BOOL CAboutDlg::GotoURL(LPCTSTR lpszUrl) const { // Try to open hyperlink SHELLEXECUTEINFO sei; memset(&sei, 0, sizeof(SHELLEXECUTEINFO)); sei.cbSize = sizeof(SHELLEXECUTEINFO); sei.fMask = SEE_MASK_FLAG_NO_UI; sei.lpVerb = _T("open"); sei.lpFile = lpszUrl; sei.nShow = SW_SHOWMAXIMIZED; return ShellExecuteEx(&sei); } void CAboutDlg::OnAboutEmail() { // TODO: Add your command handler code here GotoURL(_T("mailto:email@pocketpcdn.com")); } void CAboutDlg::OnAboutHomepage() { // TODO: Add your command handler code here GotoURL(_T("http://www.hh-system.com/danielstrigl")); }

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House