方案一:
ShellExecute打开新的url链接
SHSTDAPI_(HINSTANCE) ShellExecuteA(_In_opt_ HWND hwnd, _In_opt_ LPCSTR lpOperation, _In_ LPCSTR lpFile, _In_opt_ LPCSTR lpParameters,
_In_opt_ LPCSTR lpDirectory, _In_ INT nShowCmd);
SHSTDAPI_(HINSTANCE) ShellExecuteW(_In_opt_ HWND hwnd, _In_opt_ LPCWSTR lpOperation, _In_ LPCWSTR lpFile, _In_opt_ LPCWSTR lpParameters,
_In_opt_ LPCWSTR lpDirectory, _In_ INT nShowCmd);
#ifdef UNICODE
#define ShellExecute ShellExecuteW
#else
#define ShellExecute ShellExecuteA
#endif // !UNICODE
unicode编码,url参数需要转换为wchar类型
例如:
std::string str = "https://www.baidu.com"
WCHAR *url = new WCHAR[str .length() + 1];
ShellExecute方法打开链接url
ShellExecute(NULL, "open", "IEXPLORE", url, NULL, SW_SHOWNORMAL); //在新的IE浏览器窗口中打开