获取“接口WUApiLib.IAutomaticUpdates2的QueryInterface失败".信息. [英] Getting "QueryInterface for interface WUApiLib.IAutomaticUpdates2 failed" message.

查看:147
本文介绍了获取“接口WUApiLib.IAutomaticUpdates2的QueryInterface失败".信息.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在.Net 1.1中编写一个C#程序,以了解Windows的检查更新".地位.因此,我正在使用wuapi dll来获取接口和api.但是我收到的是接口WUApiLib的QueryInterface.IAutomaticUpdates2失败" 为"AutomaticUpdatesClass"创建实例时出现异常班级.请给我建议正确的方法.下面是我的代码段.

I'm writing a C# program in .Net 1.1 to know the windows "Check Updates" status. Hence, I'm using wuapi dll to get the interfaces and api's. But I'm getting "QueryInterface for interface WUApiLib.IAutomaticUpdates2 failed" exception while creating the instance for "AutomaticUpdatesClass" class. Kindly suggest me the proper way to do this. Below is my code snippet.

Console.ReadLine();

Console.ReadLine();

推荐答案

您好,Nataraj NM,

Hi Nataraj NM,

谢谢您在这里发布.

对于您的问题,我下载了 wuapi dll 并尝试一下.您可以尝试以下代码来获取Windows更新状态.我尝试过这个.效果很好.

For your question, I download wuapi dll and have a try.  You could try the following code to get the Windows update states. I tried it. It works well.

在设计器中.

这是代码.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WUApiLib;

namespace check_update
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            UpdateSession uSession = new UpdateSession();
            IUpdateSearcher uSearcher = uSession.CreateUpdateSearcher();
            uSearcher.Online = false;
            try
            {
                ISearchResult sResult = uSearcher.Search("IsInstalled=1 And IsHidden=0");
                textBox1.Text = "Found " + sResult.Updates.Count + " updates" + Environment.NewLine;
                foreach (IUpdate update in sResult.Updates)
                {
                    textBox1.AppendText(update.Title + Environment.NewLine);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong: " + ex.Message);
            }
        }

    }
}

这是输出.

最好的问候,

温迪


这篇关于获取“接口WUApiLib.IAutomaticUpdates2的QueryInterface失败".信息.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆