【问题标题】:InternetCrackUrl() functionInternetCrackUrl() 函数
【发布时间】:2014-09-25 10:38:33
【问题描述】:

当我尝试在 URL_COMPONENTS 结构中破解我的 URL 时,我的这个函数有点问题,HostName 和 urlPath 成员的值保持在 '\0' 同时它是这样的,我有真正的长度两者(HostName 和 urlPath 成员)。 有什么问题?,如果您通过代码回答,我会很高兴。

感谢和最良好的祝愿, 约翰·史密斯。

URL_COMPONENTS urlcomponents;
urlcomponents.dwStructSize=sizeof(URL_COMPONENTS);
urlcomponents.dwHostNameLength=10;
urlcomponents.dwPasswordLength=10;
urlcomponents.dwSchemeLength=10;
urlcomponents.dwUrlPathLength=10;
urlcomponents.dwUserNameLength=10;
urlcomponents.dwExtraInfoLength=10;
urlcomponents.lpszExtraInfo=extraInfo;
urlcomponents.lpszHostName=hostName;
urlcomponents.lpszPassword=passwordSet;
urlcomponents.lpszScheme=schemeUrl;
urlcomponents.lpszUrlPath=fileUrlPath;
urlcomponents.lpszUserName=userName;
//urlcomponents.nPort=80;

std::string originUrl="http://s1.asandownload.com/mobile/android/application/Color.Effect.Booth.Pro.v1.4.2_AsanDl.com.apk";

InternetCrackUrl(originUrl.c_str(),originUrl.Length(),0,&urlcomponents);

【问题讨论】:

    标签: c++ parsing winapi url wininet


    【解决方案1】:

    问题解决了,我会在这里分享:D

    很明显,当 GetLastError 返回 ERROR_INSUFFICIENT_BUFFER 看在上帝的份上,您需要增加某些东西的长度或大小!!! :D 所以,我增加了它:D, 例如:

    urlcomponents.dwHostNameLength=1024;
    

    因为我的缓冲区大小是

    =new char [1024];
    

    太棒了!

    【讨论】:

      【解决方案2】:

      您将originUrl.c_str() 传递给InternetCrackUrl()dwUrlLength 参数。您需要通过 0originUrl.length() 代替。您还应该检查 InternetCrackUrl() 的返回值是否失败。

      if (!InternetCrackUrl(originUrl.c_str(),originUrl.length(),0,&urlcomponents))
      {
          DWORD ErrCode - GetLastError();
          ...
      }
      

      【讨论】:

      • 是的,很抱歉,我只是在这里写了它,在真实代码中我测试了 originUrl.Length() 和 0,但它们没有工作。顺便说一句,当我使用 GetLastError 时,它说:ERROR_INSUFFICIENT_BUFFER 122 (0x7A) 传递给系统调用的数据区域太小。我该怎么办?
      猜你喜欢
      • 1970-01-01
      • 2020-01-02
      • 2016-11-23
      • 1970-01-01
      • 2017-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多