首页 新闻 会员 周边 捐助

c#获取网址上控件报错

0
悬赏园豆:5 [已关闭问题] 关闭于 2018-12-28 15:40

贴一下代码
private IHTMLSelectElement getSelectElement(IHTMLDocument2 document, string id)
{
var obj = (document as IHTMLDocument3).getElementById(id) as IHTMLSelectElement;
if (obj == null)
{
IHTMLFramesCollection2 frames = (IHTMLFramesCollection2)document.frames;
for (int i = 0; i < frames.length; i++)
{
try
{
IHTMLWindow2 frame = frames.item(i) as IHTMLWindow2;
IHTMLDocument2 frameDoc = frame.document;
obj = (frameDoc as IHTMLDocument3).getElementById(id) as IHTMLSelectElement;
if (obj != null)
{
break;
}
}
catch
{
}
}
}
return obj;
}}}
private IHTMLInputButtonElSHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
string filename = System.IO.Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
string url = ie.LocationURL.ToUpper();

                //地址匹配 getRegQuery
                //if (url.IndexOf("GETREGQUERY") >= 0)
                if (isLockUrl(url))  
                {
                    IHTMLDocument2 document = ie.Document as IHTMLDocument2;
                    while (document.readyState != "complete")
                    {
                        Thread.Sleep(500);
                    }

                    //业务类型
                    string gnid = "";
                    var gnidObj = getSelectElement(document, "gnid");
                    if (gnidObj != null)
                    {
                        gnid = gnidObj.value;

                        //默认设置
                        //身份证明号码
                        var sfzmhmObj = getInputTextElement(document, "sfzmhm");
                        if (sfzmhmObj != null)
                        {
                            sfzmhmObj.readOnly = false;
                        }
                        //号牌种类
                        var hpzlObj = getSelectElement(document, "hpzl");
                        if (hpzlObj != null)
                        {
                        }
                        var hpzl1Obj = getSelectElement(document, "hpzl1");
                        if (hpzl1Obj != null)
                        {
                        }
                        //号牌号码
                        var hphmObj = getInputTextElement(document, "hphm");
                        if (hphmObj != null)
                        {
                            hphmObj.readOnly = false;
   

}

}
}

TS朝暮的主页 TS朝暮 | 初学一级 | 园豆:10
提问于:2018-12-28 15:04
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册