JG Vimalan's Blog

It is all about coding!

Handling windows of other processes

In this post, I am going to explain bringing a minimized window of other process to normal state.  Inorder to do that, you need to use the ‘showwindow’ api from win32. The detailed code is given below,

        private static extern int ShowWindow(int hwnd, int nCmdShow);

implement the ShowWindow in a method.

                    System.Diagnostics.Process[] mygameProcess = System.Diagnostics.Process.GetProcessesByName(“mygame”);
                    if (mygameProcess.Length > 0)
                        System.Diagnostics.Process proc = mygameProcess[0];                       
                        TvStarter.ShowWindow(proc.MainWindowHandle.ToInt32(), 1); //TvStarter is class name                        
                    //log exception

this is very useful when you create an application which controls several other related applications in .Net.

November 26, 2010 - Posted by | C#.NET

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: