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!