Iwebbrowser2 导航:未提交后期数据
Iwebbrowser2 Navigate: No post-data submitted
我正在使用IWebbrowser2
接口来调用页面并向其提交一些POST数据。IE被打开,页面被调用,但不幸的是没有提交POST数据(PHP服务器上的$_POST数组是空的)。有人能告诉我为什么吗?
主要方法中的相关部分:
BSTR bstrURL2;
bstrURL2 = SysAllocString(L"http://www.mypage.com/");
// Specify a binary Content-Type.
V_BSTR(&vHeaders) = SysAllocString(
L"Content-Type: application/x-www-form-urlencodedrn"
L"Content-Encoding: UTF-8rn");
VARIANT vPostData = {0};
if (Navigate::GetPostData(&vPostData) == NOERROR)
r->Navigate(bstrURL2, &vFlags, &vEmpty, &vPostData, &vHeaders);
GetPostData-method:
HRESULT Navigate::GetPostData(LPVARIANT pvPostData)
{
HRESULT hr;
LPSAFEARRAY psa;
LPCTSTR cszPostData = "username=myusername&password=mypassword";
UINT cElems;
LPSTR pPostData;
cElems = lstrlen(cszPostData);
if (!pvPostData)
{
return E_POINTER;
}
VariantInit(pvPostData);
psa = SafeArrayCreateVector(VT_UI1, 0, cElems);
if (!psa)
{
return E_OUTOFMEMORY;
}
hr = SafeArrayAccessData(psa, (LPVOID*)&pPostData);
memcpy(pPostData, cszPostData, cElems);
hr = SafeArrayUnaccessData(psa);
V_VT(pvPostData) = VT_ARRAY | VT_UI1;
V_ARRAY(pvPostData) = psa;
return NOERROR;
}
我试图重现您的示例,当我定义vHeader
变量的类型时它有效:
// Specify a binary Content-Type.
V_VT(&vHeaders) = VT_BSTR;
V_BSTR(&vHeaders) = SysAllocString(L"Content-Type: application/x-www-form-urlencodedrnContent-Encoding: UTF-8rn");
看这里: https://support.microsoft.com/en-us/kb/167658
相关文章:
- 防止主数据类型C++的隐式转换
- 用于访问容器<T>数据成员的正确 API
- 嵌套在类中时无法设置成员数据
- 使用流处理接收到的数据
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 在cuda线程之间共享大量常量数据
- C++将文本文件中的数据读取到结构数组中
- 如何在C++中序列化结构数据
- 在C++中打印指向不同基元数据类型的指针的内存地址
- 通过套接字[TCP]传输数据 如何在C / C ++中打包多个整数并使用send() recv()传输数据
- 在c代码之间共享数据的最佳方式
- 在Google Kick start中提交时出错
- 链表,反向函数,数据结构
- 数据成员SFINAE的C++17测试:gcc vs clang
- C++浮点数据类型和字符串数据类型无法子到模板函数中
- Iwebbrowser2 导航:未提交后期数据
- 使用excel表格中的数据填充web文本字段,提交页面,重复
- Qt QItemDelegate提交数据并在鼠标上关闭编辑器,离开视图小部件(listView)
- 在提交数据的SQLite连接之间是否存在传播延迟