找回密码
 加入
搜索
查看: 4982|回复: 10

[网络通信] 关于winhttp udf的

  [复制链接]
发表于 2011-2-19 17:02:57 | 显示全部楼层 |阅读模式
最近发现用 _WinHttpCrackUrl 后面的 $iFlag = Default 会自动把 提交页面 中的url字符转换成 乱码 求解决 或者 让 crackurl的过程中 不处理 iflag的转换

$ICU_DECODE - 转换 "escape encoded" 字符(%xx) 为非 escaped 结构.
$ICU_ESCAPE - Escapes 若干字符为它们的转义序列 (%xx).


Func _WinHttpCrackUrl($sURL, $iFlag = Default)
        If $iFlag = Default Or $iFlag = -1 Then $iFlag = $ICU_ESCAPE
        Local $tURL_COMPONENTS = DllStructCreate("dword StructSize;" & _
                        "ptr SchemeName;" & _
                        "dword SchemeNameLength;" & _
                        "int Scheme;" & _
                        "ptr HostName;" & _
                        "dword HostNameLength;" & _
                        "word Port;" & _
                        "ptr UserName;" & _
                        "dword UserNameLength;" & _
                        "ptr Password;" & _
                        "dword PasswordLength;" & _
                        "ptr UrlPath;" & _
                        "dword UrlPathLength;" & _
                        "ptr ExtraInfo;" & _
                        "dword ExtraInfoLength")
        DllStructSetData($tURL_COMPONENTS, 1, DllStructGetSize($tURL_COMPONENTS))
        Local $tBuffers[6]
        Local $iURLLen = StringLen($sURL)
        For $i = 0 To 5
                $tBuffers[$i] = DllStructCreate("wchar[" & $iURLLen + 1 & "]")
        Next
        DllStructSetData($tURL_COMPONENTS, "SchemeNameLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "SchemeName", DllStructGetPtr($tBuffers[0]))
        DllStructSetData($tURL_COMPONENTS, "HostNameLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "HostName", DllStructGetPtr($tBuffers[1]))
        DllStructSetData($tURL_COMPONENTS, "UserNameLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "UserName", DllStructGetPtr($tBuffers[2]))
        DllStructSetData($tURL_COMPONENTS, "PasswordLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "Password", DllStructGetPtr($tBuffers[3]))
        DllStructSetData($tURL_COMPONENTS, "UrlPathLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "UrlPath", DllStructGetPtr($tBuffers[4]))
        DllStructSetData($tURL_COMPONENTS, "ExtraInfoLength", $iURLLen)
        DllStructSetData($tURL_COMPONENTS, "ExtraInfo", DllStructGetPtr($tBuffers[5]))
        Local $aCall = DllCall($hWINHTTPDLL__WINHTTP, "bool", "WinHttpCrackUrl", _
                        "wstr", $sURL, _
                        "dword", $iURLLen, _
                        "dword", $iFlag, _
                        "ptr", DllStructGetPtr($tURL_COMPONENTS))
        If @error Or Not $aCall[0] Then Return SetError(1, 0, 0)
        Local $aRet[8] = [DllStructGetData($tBuffers[0], 1), _
                        DllStructGetData($tURL_COMPONENTS, "Scheme"), _
                        DllStructGetData($tBuffers[1], 1), _
                        DllStructGetData($tURL_COMPONENTS, "Port"), _
                        DllStructGetData($tBuffers[2], 1), _
                        DllStructGetData($tBuffers[3], 1), _
                        DllStructGetData($tBuffers[4], 1), _
                        DllStructGetData($tBuffers[5], 1)]
        Return $aRet
EndFunc   ;==>_WinHttpCrackUrl
发表于 2011-2-19 17:43:26 | 显示全部楼层
_WinHttpCrackUrl($sURL, $ICU_DECODE) 不行吗?
 楼主| 发表于 2011-2-19 17:51:42 | 显示全部楼层
现在用的就是  $ICU_DECODE  

viewtype=%E6%9C%AA%E5%88%86%E7%BB%84%E5%A5%BD%E5%8F%8B&start=

变成

viewtype=鏈?垎缁勫ソ鍙?start=
 楼主| 发表于 2011-2-21 00:46:15 | 显示全部楼层
dddddddddddddddd
发表于 2011-2-21 11:36:10 | 显示全部楼层
给个网址看看,并且说明下你想干嘛?
发表于 2011-2-24 22:23:52 | 显示全部楼层
我也是同样的问题啊!!!没办法~~~~~
发表于 2011-2-24 23:14:05 | 显示全部楼层
_WinHttpCrackUrl( )  $sURL中 有汉字,且超过7个就是不行
发表于 2011-2-25 08:16:35 | 显示全部楼层
人工修改  $aUrl = _WinHttpCrackUrl()后的 $aUr[7] 试试不知如何
发表于 2011-2-25 09:04:56 | 显示全部楼层
给个完整的URL测试下
发表于 2011-2-28 22:04:00 | 显示全部楼层
七个汉字的人工修改  $aUrl = _WinHttpCrackUrl()后的 $aUr[7] 成功。
 楼主| 发表于 2011-3-2 15:36:26 | 显示全部楼层
我直接倒回去了 直接用汉字提交。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-19 08:37 , Processed in 0.078521 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表