18,356
社区成员
发帖
与我相关
我的任务
分享
CComQIPtr<IHTMLDocument3> spDocument = m_IE.get_Document();
CComQIPtr<IHTMLInputElement> spInputElement;
CComPtr<IHTMLElement> spElement;
//填写账号
spDocument->getElementById(L"txtUser", &spElement);
spInputElement = spElement;
spInputElement->put_value(L"admin");
spElement.Release();
//填写密码
spDocument->getElementById(L"txtPassWord", &spElement);
spInputElement = spElement;
spInputElement->put_value(L"123456");
spElement.Release();
//点击登录按钮
spDocument->getElementById(L"butLogin", &spElement);
spElement->click();
写在一个按钮响应函数里,等页面加载完成后,点这个按钮试一下。如果程序崩溃了,调试下看看,哪一步出现空指针。