我用DELPHI写下段代码
var
flags : OLEVariant;
framename :OLEVariant;
postdata : OLEVariant;
begin
flags := 0;
framename :='';
postdata := 'Account='+G_Login+'&Password='+G_PWD;
WebBrowser1.Navigate(G_LoginASP,flags,framename,postdata);
end;用sniffer查看,发现发送出去的是GET方法。未知错在哪
var
flags : OLEVariant;
framename :OLEVariant;
postdata : OLEVariant;
begin
flags := 0;
framename :='';
postdata := 'Account='+G_Login+'&Password='+G_PWD;
WebBrowser1.Navigate(G_LoginASP,flags,framename,postdata);
end;用sniffer查看,发现发送出去的是GET方法。未知错在哪
解决方案 »
- 为何loadlibrary 返回 0
- [matlab]builder for COM 出现 The chosen compiler does not support building COM objects
- (0x05000000) 问题
- 多个窗口的数据传递问题!!!急,在线等。
- 谁能讲讲数据库操作(打开,执行SQL,处理结果
- c++里生成随机数的函数是什么(?
- 两个字符串指针比较大小是什么意思?
- 求检测道路直线去除杂点问题(用CVI)
- 大家给看看这段代码有什么问题?
- 抢答,EditBox中显示超过它默认大小的文件内容,应该如何处理?急!!!
- 关闭窗口
- 我重载了CListCtrl,增加了一个CEDIT,debug下没问题,release下出错..........
用
CHttpConnection* pConnection = NULL;
CHttpFile* pFile = NULL;
CInternetSession *psession = NULL;
psession = new CInternetSession(
NULL,
1,
INTERNET_OPEN_TYPE_PRECONFIG);
pConnection = psession->GetHttpConnection(strServer);
pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, _T(cgi)); pFile->SendRequestEx(intXX);
pFile->Write(pZipData,intXX);
pFile->EndRequest();
delete[] pZipData;
Syntax
object.Navigate2 URL [Flags,] [TargetFrameName,] [PostData,] [Headers]
PostData Optional. Data to send to the server during the HTTP POST transaction. For example, the POST transaction is used to send data gathered by an HTML form to a program or script. If this parameter does not specify any post data, the Navigate2 method issues an HTTP GET transaction. This parameter is ignored if URL is not an HTTP URL.
Headers Optional. A value that specifies additional HTTP headers to send to the server. These headers are added to the default Internet Explorer headers. The headers can specify things like the action required of the server, the type of data being passed to the server, or a status code. This parameter is ignored if URL is not an HTTP URL.
VARIANT vPostData = {0}; // Test data length.
int len = 6; // Create test data.
char* data = new char[len]; // Copy a string, including its NULL character.
memcpy(data, "hello", len);
data[2] = '\0';
// The data now contains {he\0lo\0}. There is an embedded NULL character. // Put data into safe array.
LPSAFEARRAY psa = SafeArrayCreateVector(VT_UI1, 0, len);
if (!psa)
return;
LPSTR pPostData;
HRESULT hr=SafeArrayAccessData(psa, (LPVOID*)&pPostData);
memcpy(pPostData,data,len);
hr = SafeArrayUnaccessData(psa); // Package the SafeArray into a VARIANT.
V_VT(&vPostData) = VT_ARRAY | VT_UI1;
V_ARRAY(&vPostData) = psa;
// Get Headers.
VARIANT vHeaders = {0};
V_VT(&vHeaders) = VT_BSTR; // Specify a binary Content-Type.
V_BSTR(&vHeaders) = SysAllocString(
L"Content-Type: application/octet-stream\r\n"
L"Content-Encoding: gzip\r\n"); // Navigate, and POST the data. http://myserver/myasp.asp
// is an Active Server Pages page that expects POST data.
// m_pBrowserApp is declared as IWebBrowser2*
hr = m_pBrowserApp->Navigate(L"http://myserver/myasp.asp", &vFlags,
NULL, &vPostData, &vHeaders);
绕了好大的弯,其实这段代码就是DELPHI的variant变量机制,不需要自己明确创建一个SafeArray吧。
用DELPHI POST不了,我还是一脸茫然。