PDA

View Full Version : How to restart M3D from C#?


pp18
7th July 2009, 05:16 PM
i'm wriiting a program to update the weather info (forecast_cache.db). to force M3D to read the updated weather data, at the end the program i'd like to force M3D (the today plug-in) to restart.

i tried the following codes. it worked sometimes but not always (no effect to the today screen).


rk_m3d = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Today\\Items\\TouchFLO 3D", true);
rk_m3d.SetValue("Enabled", 0, RegistryValueKind.DWord);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);

// do some other calculation

rk_m3d.SetValue("Enabled", 1, RegistryValueKind.DWord);
PostMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);


could somebody advise a better way to force restart of M3D (or just the Weather tab)?

thanks in advance.

heliosdev
7th July 2009, 09:04 PM
You can try to kill/start it using System.Diagnostics.Process (http://msdn.microsoft.com/en-us/library/system.diagnostics.process_members.aspx) class.

pp18
8th July 2009, 07:45 AM
thanks for your reply. I checked the documentation and noticed that GetProcessByName is not supported by .net cf. would you mind advising what method I can use to get the manila.exe process handle?
thanks again.

heliosdev
8th July 2009, 01:38 PM
Take a look at this (http://msdn.microsoft.com/en-us/library/aa446560.aspx) example (class Process has a method GetProcesses())!

pp18
8th July 2009, 04:43 PM
thanks again for your reply.
though Process.GetProcesses and Process.GetProcessesByName are not available in .Net CF, the sample codes you directed is a good reference on using the Win API.
thanks again.

heliosdev
8th July 2009, 08:56 PM
Yes, you're right, sorry for that!