简体   繁体   中英

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

Some features 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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM