开发者

Can I embed an external component in a Windows 7 gadget?

Some fe开发者_高级运维atures I needed is not available in the Javascript API. Is it possible to use an external component (C++ or whatever) in a gadget? In particular, I'd like to get a list of running processes.


You can access WMI objects (or pretty much any COM object) from a gadget. For example the following WMI JScript will dump all processes on the system to the gadget window (put it in the HTML).

try {
    var wmi = GetObject("winmgmts:\\\\.\\root\\CIMV2");
    var items = wmi.ExecQuery("SELECT * FROM Win32_Process");
    var i = 0;

    while(i < items.Count)
    {
         var item = items.ItemIndex(i);
         document.writeln(item.Name);       
         i++;
    }
} catch(e) {
    document.write(e.message);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜