How to use Windows API functions to open web pages

Source: Internet
Author: User

Many examples on the internet provide methods similar to this,

ShellExecute(NULL, L"open", L"http://www.hao123.com", NULL, NULL, SW_SHOWNORMAL);

I personally tested it in Windows 7 + VS08. the test method may produce a running error, but I checked the ShellExecute Function.

ShellExecute (HWND hwnd, // parent window Handle such as: NULL, Handle, etc.) LPCSTR lpOperation, // operation type such as: "open") * to add an English double quotation mark (double quotation mark) LPCSTR lpFile, // The file or path to which the operation is to be performed: LPCSTR lpParameters. // when lpOperation is set to "too E", specify the parameter to be passed. This parameter is usually set to NULL. lpDirectory: // specify the default directory, it is usually set to null int nShowCmd // The method for opening a file. The display mode is usually maximized or minimized, generally SW_SHOWNORMAL)

We found that the call seems to be correct, but this method is not feasible in VS08!

As a result, I found that many people have provided such a solution on the Internet.

ShellExecute(NULL, L"open", L"IEXPLORE", STR_FINISH_PAGE_WEB_SITE, NULL, SW_SHOWMAXIMIZED);
In this way, the web page can be opened, but the default is that IE opens the web page. Such a solution will drive many players crazy, and IE will be used to open a Web page, no need for this software!

After a series of research, I finally found a way to open the web page with the default browser: the solution is as follows:

ShellExecute(NULL, L"open", L"Explorer.exe", STR_FINISH_PAGE_WEB_SITE, NULL, SW_SHOWMAXIMIZED);

Check whether the code is different from the parameter given by the function!



This article is from the "selling cute programmers" blog and is not reposted!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.