简体   繁体   中英

C++ ShellExecute a URL

Tried googling for a few hours, testing different solutions for hours but still just cannot get this to work.

I need a const url base (Ex. http://www.google.com ) Then I need a string input from the user (ex. Mountain Dew) and then combine them. I've tried making the URL a LPCWSTR, wstring, wchar_t, doing a function to convert them and combine them but I cannot get it to work at all.

std::string baseUrl = "http://www.google.com/";
std::string userAdd;
getline(std::cin, userAdd)
ShellExecute(NULL, TEXT("open"), baseUrl + userAdd, NULL, NULL, SW_SHOWNORMAL);

There's no automatic conversion from std::string to const char*.

Try this: (baseUrl + userAdd).c_str()

and try using ShellExecuteA

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM