关于TCppWebBrowser的post数据问题,如下代码无法正确提交参数。请指教(200分)

  • 主题发起人 主题发起人 秋之叶
  • 开始时间 开始时间

秋之叶

Unregistered / Unconfirmed
GUEST, unregistred user!
void callWebServer(TCppWebBrowser *WebBrowser, String sURL, String sPostData)
{
BSTR bstrHeaders = NULL;
TVariant vFlags = {0}, vTargetFrameName={0}, vPostData={0}, vHeaders={0};
LPSAFEARRAY psa;
LPCTSTR cszPostData = sPostData.c_str();
UINT cElems = lstrlen(cszPostData);
LPSTR pPostData;
LPVARIANT pvPostData;
bstrHeaders = SysAllocString(L"Content-Type: application/x-www-form-urlencodedrn");
if (!bstrHeaders){
Application->MessageBox("Could not allocate bstrHeaders", "Warning", MB_OK | MB_ICONWARNING);
return;
}
V_VT(&vHeaders) = VT_BSTR;
V_BSTR(&vHeaders) = bstrHeaders;
pvPostData = vPostData;
if(pvPostData){
VariantInit(pvPostData);
psa = SafeArrayCreateVector(VT_UI1, 0, cElems);
if(!psa){
return;
}
SafeArrayAccessData(psa, (LPVOID*)&pPostData);
memcpy(pPostData, cszPostData, cElems);
SafeArrayUnaccessData(psa);
V_VT(pvPostData) = VT_ARRAY | VT_UI1;
V_ARRAY(pvPostData) = psa;
}
WebBrowser->Navigate((TVariant)sURL, &vFlags, &vTargetFrameName, &vPostData, &vHeaders);
}
 
后退
顶部