【问题标题】:How to compare strstr(LPCWSTR, CHAR*);如何比较 strstr(LPCWSTR, CHAR*);
【发布时间】:2012-11-06 11:03:00
【问题描述】:
LPCWSTR location_url;
m_spWebBrowser->get_LocationURL((BSTR*)&location_url);

如何比较 LPCWSTRconst char * 中的 strstr

例子:

if(strstr((location_url, ".html"))

【问题讨论】:

  • get_LocationURL() 返回实际的BSTR,而不是LPWSTR。您需要修复变量声明。并且不要忘记在使用完毕后调用SysFreeString(),否则会出现内存泄漏。

标签: c++ c winapi visual-c++


【解决方案1】:

您也可以将目标扩展名设为宽字符串并使用wcsstr

wchar_t* ext = L".html";
if (wcsstr(location_url, ext))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 1970-01-01
    相关资源
    最近更新 更多