草庐IT

DSlashLoc

全部标签

windows - 将 const wchar_t* 转换为 const char*

我正在尝试使用GetHostByName(),这需要一个constchar*。我的URL位于成本wchar_t*格式的变量中。我如何转换它以便GetHostByName可以使用它?代码。BSTRbstr;pBrowser->get_LocationURL(&bstr);std::wstringwsURL;wsURL=bstr;size_tDSlashLoc=wsURL.find(L"://");if(DSlashLoc!=wsURL.npos){wsURL.erase(wsURL.begin(),wsURL.begin()+DSlashLoc+3);}DSlashLoc=wsURL.f