Re: How to submit password or ID automatically
- From: GGL <GGL@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Apr 2006 22:01:01 -0700
Following code is my program.
I try to send ID and PW to http://www.hennlong.idv.tw/cgi-bin/loginout.cgi
But when I click the button to send messge to the url, it just open a new IE
window and link to
http://www.hennlong.idv.tw/cgi-bin/loginout.cgi . No message send to the URL
, beacuse the open page just the homepage not the ID/PW error page.
//Button Click
HRESULT hr;
CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> mWebBrowser2;
BSTR bstrURL = NULL, bstrHeaders = NULL;
VARIANT vFlags = {0},vTargetFrameName = {0},vPostData = {0},vHeaders = {0};
if (FAILED(hr = CoInitialize(NULL)))
return;
if (FAILED(hr =
CoCreateInstance(CLSID_InternetExplorer,NULL,CLSCTX_SERVER,IID_IWebBrowserApp,(LPVOID*)&mWebBrowser2)))
MessageBoxW(NULL,L"CoCreateInstance....",L"Warning",MB_OK | MB_TASKMODAL);
bstrURL = SysAllocString(L"http://www.hennlong.idv.tw/cgi-bin/loginout.cgi");
if (!bstrURL)
MessageBoxW(NULL,L"bstrURL....",L"Warning",MB_OK | MB_TASKMODAL);
bstrHeaders = SysAllocString(L"Content-Type:
application/x-www-form-urlencoded\r\n");
if (!bstrHeaders)
MessageBoxW(NULL,L"bstrHeaders....",L"Warning",MB_OK | MB_TASKMODAL);
V_VT(&vHeaders) = VT_BSTR;
V_BSTR(&vHeaders) = bstrHeaders;
GetPostData(&vPostData);
mWebBrowser2->Navigate(bstrURL, &vFlags,&vTargetFrameName, &vPostData,
&vHeaders);
mWebBrowser2->put_Visible(VARIANT_TRUE);
//-------------------------------------------
HRESULT CIEPlugin::GetPostData(LPVARIANT pvPostData)
{
HRESULT hr;
LPSAFEARRAY psa;
LPCTSTR cszPostData = L"?inmembername=test&inpassword=testpw";
UINT cElems = lstrlen(cszPostData);
LPSTR pPostData;
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;
}
"Igor Tandetnik" wrote:
"GGL" <GGL@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message.
news:D8DA6DA8-2B15-4C93-887F-2D1559A9D9F4@xxxxxxxxxxxxx
In the exapmle page, it has one line :
bstrHeaders = SysAllocString( L"Content-Type:
application/x-www-form-urlencoded\r\n");
But all my login website don't have the same Header. Even no page
have the similar header.
Browser sends this header automatically whenever it submits a form. You
won't see it in the HTML content of the page, if that's what you are
expecting.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Follow-Ups:
- Re: How to submit password or ID automatically
- From: Igor Tandetnik
- Re: How to submit password or ID automatically
- From: GGL
- Re: How to submit password or ID automatically
- References:
- Re: How to submit password or ID automatically
- From: Igor Tandetnik
- Re: How to submit password or ID automatically
- Prev by Date: Re: How to submit password or ID automatically
- Next by Date: Re: How to submit password or ID automatically
- Previous by thread: Re: How to submit password or ID automatically
- Next by thread: Re: How to submit password or ID automatically
- Index(es):