이렇게 했는데 값이 안들어가는거 같아요
LPDISPATCH lpDispatch = NULL;
lpDispatch = m_ctrlWebBrowser.GetDocument(); // m_ctrlWebBrowser : 웹 컨트롤
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 bstrName=NULL, bstrNo1=NULL, bstrNo2=NULL; //이름, 주민번호 앞, 뒤
if(j == 0){
bstrName = m_strName.AllocSysString(); //이름
hr = pInputEle->put_name(bstrName);
if(SUCCEEDED(hr)) ::SysFreeString(bstrName);
}
else if(j == 1){
bstrNo1 = m_strNo1.AllocSysString();
hr = pInputEle->put_name(bstrNo1); //번호앞
if(SUCCEEDED(hr)) ::SysFreeString(bstrNo1);
}
else if(j == 2){
bstrNo2 = m_strNo2.AllocSysString();
hr = pInputEle->put_name(bstrNo2); //번호뒤
if(SUCCEEDED(hr)) ::SysFreeString(bstrNo2);
}
else continue;
//해제
pInputEle->Release();
lpItem->Release();
}
pFormEle->submit();
pFormEle->Release();
pFormEleItem->Release();
}
pEleCollection->Release();
//pEle->Release();
//pEle = NULL;
}
pHTMLDocument2->Release();
pHTMLDocument2 = NULL;
}
}
파란색 부분에서 에러가 나는거 같은데 어떻게 해야 될까요
선배님들 조언 기다리겠습니다 |