我用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方法。未知错在哪

解决方案 »

  1.   

    这样是不行的

    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;
      

  2.   

    http://www.csdn.com.cn/program/1598.htm
      

  3.   

    Navigate2 Method
    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.  
      

  4.   

    but how to call Navigate() to POST data?my URL is right, postdata not null. according to document, my call must use post method.
      

  5.   

    The following code sample tries to call IWebBrowser2::Navigate to POST data:  VARIANT vFlags = {0};
    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);
      

  6.   

    to  kingzai(stevenzhu):
    绕了好大的弯,其实这段代码就是DELPHI的variant变量机制,不需要自己明确创建一个SafeArray吧。
    用DELPHI POST不了,我还是一脸茫然。