우선 소스를 보면은 이렇습니다..
LPDISPATCH lpDispatch = NULL;
lpDispatch = m_webBrowser.GetDocument(); // m_WebBrowser : 웹 컨트롤
IHTMLDocument2 * pHTMLDocument2 = NULL;
HRESULT hr = E_FAIL;
if (lpDispatch)
{
HRESULT hr = lpDispatch->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&pHTMLDocument2);
if(SUCCEEDED(hr))
{
IHTMLElement * pEle = NULL;
IHTMLElementCollection* pEleCollection = NULL;
IHTMLInputTextElement* pInputEle = NULL;
IHTMLFormElement* pFormEle = NULL;
long len = 0, lElementLen = 0;
LPDISPATCH pFormEleItem;
LPDISPATCH lpItem;
//폼을 구하고
hr = pHTMLDocument2->get_forms(&pEleCollection);
if(SUCCEEDED(hr))
{
//구한 폼들 개수
pEleCollection->get_length(&len);
for(int i = 0; i < len; i++)
{
hr = pEleCollection->item(CComVariant(i), CComVariant(i), &pFormEleItem);
if(FAILED(hr)) continue;
hr = pFormEleItem->QueryInterface(IID_IHTMLFormElement, (void**)&pFormEle);
if(FAILED(hr)) continue;
pFormEle->get_length(&lElementLen);
for(int j = lElementLen - 1; j >= 0; j--){
hr = pFormEle->item(CComVariant(j), CComVariant(j), &lpItem);
if(FAILED(hr)) continue;
hr = lpItem->QueryInterface(IID_IHTMLInputTextElement, (void**)&pInputEle);
if(FAILED(hr)) continue;
//아이디, 비번
BSTR bstrId=NULL, bstrPass=NULL;
if(j == 0){
//아이디
bstrId = m_Listen.m_Client.s_id.AllocSysString();
hr = pInputEle->put_value(bstrId);
if(SUCCEEDED(hr)) ::SysFreeString(bstrId);
}
else if(j == 1){
bstrPass = m_Listen.m_Client.s_pass.AllocSysString();
//비번
hr = pInputEle->put_value(bstrPass);
if(SUCCEEDED(hr)) ::SysFreeString(bstrPass);
}
else continue;
//해제
pInputEle->Release();
lpItem->Release();
}
pFormEle->submit();
pFormEle->Release();
pFormEleItem->Release();
}
pEleCollection->Release();
}
pHTMLDocument2->Release();
pHTMLDocument2 = NULL;
}
}
근데 이렇게 해서 실행을 하면요 제가 만든 홈페이지에서는 아이디랑 비밀번호가 잘들어가는데요
네이버랑 다음에서하면은 증권으로 들어가네요..
왜그런지좀 알려주세요...ㅠㅠ
몇일 봤지만 계속 제자리네요..ㅠㅠ |