方案一:
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瀏覽器窗口中打開