views:

26

answers:

1

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.

+1  A: 

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);
}
tyranid