I worked on a WPF app to display my PC information on the desktop. The application uses the ManagementObjectSearcher class to get the required information, and some PInvoke functions to send my window to the back, so that it looks like sticking to the desktop.
Func<string, ManagementObjectCollection> GetQueryResult = x =>
{
var __WqlQuery = new WqlObjectQuery("select * from " + x);
return new ManagementObjectSearcher(__WqlQuery).Get();
};
public static class WindowHelper
{
[DllImport("user32.dll")]
internal static extern int SetWindowPos(System.IntPtr pHWND, System.IntPtr pAfterHWND, int pX, int pY, int pCX, int pCY, int pFlags);
internal static readonly System.IntPtr HWND_BOTTOM = new System.IntPtr(0x01);
internal const int SWP_NOACTIVATE = 0x10;
internal const int SWP_NOMOVE = 0x02;
internal const int SWP_NOSIZE = 0x01;
public static void SendWpfWindowBack(ref Window window)
{
var hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
}
My desktop screen looks like…
If you are interested in the source code, leave a comment with your email address and I’ll mail you the application. I created a minimal WIX setup project so that you can install and uninstall the app from the ADD/Remove programs and have a start menu shortcut for launching the app.
3 comments:
Prajeesh, looks very interesting. I would definitely like a copy of the source code, if you don't mind. Rather than putting my email address here (I'm concerned someone may harvest it), would it be possible for you to upload the source code into sourceforge or codeplex instead? Thanks.
Pete.
Hi Pete,
You can download the source code from codeplex. I have created a project for uploading the source code from my blog.
http://prajeeshprathap.codeplex.com/
Prajeesh
Thanks, Prajeesh. Will check it out now. :) Cheers.
Pete.
Post a Comment