开发者

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

开发者 https://www.devze.com 2022-12-18 05:49 出处:网络
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 runni

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

精彩评论

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

关注公众号